Generate 3D perlin noise and multi-layered noise.
More...
#include <PerlinNoise.hpp>
|
| PerlinNoise () |
|
void | generate (Image &image, uint channel, float scale, float z, const glm::vec3 &offset=glm::vec3(0.0f)) |
|
void | generatePeriodic (Image &image, uint channel, float scale, float z, const glm::vec3 &offset=glm::vec3(0.0f)) |
|
void | generateLayers (Image &image, uint channel, int octaves, float gain, float lacunarity, float scale, const glm::vec3 &offset=glm::vec3(0.0f)) |
|
void | reseed () |
|
|
float | dotGrad (const glm::ivec3 &ip, const glm::vec3 &dp) |
|
float | perlin (const glm::vec3 &p, const glm::ivec3 &w=glm::ivec3(kHashTableSize-1)) |
|
|
std::array< int, 2 *kHashTableSize > | _hashes |
| Permutation table.
|
|
Image | _directions |
| random unit sphere directions.
|
|
|
static const int | kHashTableSize = 256 |
| Number of hashes used for the generation, limit the periodicity.
|
|
Generate 3D perlin noise and multi-layered noise.
◆ PerlinNoise()
PerlinNoise::PerlinNoise |
( |
| ) |
|
Constructor. Initialize the randomness table.
◆ dotGrad()
float PerlinNoise::dotGrad |
( |
const glm::ivec3 & |
ip, |
|
|
const glm::vec3 & |
dp |
|
) |
| |
|
private |
Compute the dot product between a direction vector and the gradient at a (ix, iy, iz) location on the grid.
- Parameters
-
ip | the grid vertex location |
dp | the direction vector |
- Returns
- the dot product
◆ generate()
void PerlinNoise::generate |
( |
Image & |
image, |
|
|
uint |
channel, |
|
|
float |
scale, |
|
|
float |
z, |
|
|
const glm::vec3 & |
offset = glm::vec3(0.0f) |
|
) |
| |
Fill a component of an image with Perlin noise in [-1,1].
- Parameters
-
image | image to fill with preset dimensions |
channel | the channel of the image to fill |
scale | the frequency, in pixels |
z | the depth (in pixels) at which the 3D Perlin noise should be sampled |
offset | the origin in sampled noise space |
◆ generateLayers()
void PerlinNoise::generateLayers |
( |
Image & |
image, |
|
|
uint |
channel, |
|
|
int |
octaves, |
|
|
float |
gain, |
|
|
float |
lacunarity, |
|
|
float |
scale, |
|
|
const glm::vec3 & |
offset = glm::vec3(0.0f) |
|
) |
| |
Fill a component of an image with multi-layered Perlin noise (FBM).
- Parameters
-
image | image to fill with preset dimensions |
channel | the channel of the image to fill
|
octaves | number of layers |
gain | the amplitude ratio between a layer and the previous one |
lacunarity | the frequency ratio between a layer and the previous one |
scale | the base frequency, in pixels |
offset | the origin in sampled noise space |
◆ generatePeriodic()
void PerlinNoise::generatePeriodic |
( |
Image & |
image, |
|
|
uint |
channel, |
|
|
float |
scale, |
|
|
float |
z, |
|
|
const glm::vec3 & |
offset = glm::vec3(0.0f) |
|
) |
| |
Fill a component of an image with tiling Perlin noise in [-1,1].
- Parameters
-
image | image to fill with preset dimensions |
channel | the channel of the image to fill |
scale | the frequency, in pixels |
z | the depth (in pixels) at which the 3D Perlin noise should be sampled |
offset | the origin in sampled noise space |
- Note
- The scale might internally be adjusted to ensure periodicity.
◆ perlin()
float PerlinNoise::perlin |
( |
const glm::vec3 & |
p, |
|
|
const glm::ivec3 & |
w = glm::ivec3(kHashTableSize-1) |
|
) |
| |
|
private |
Evaluate Perlin noise for a given location in noise space.
- Parameters
-
p | location |
w | the tiling period to apply on each axis |
- Returns
- the noise value in [-1, 1]
◆ reseed()
void PerlinNoise::reseed |
( |
| ) |
|
Regenerate the randomness table with new values.
The documentation for this class was generated from the following files:
- src/engine/generation/PerlinNoise.hpp
- src/engine/generation/PerlinNoise.cpp