Ocular Engine
Ocular::Math::Noise::SimplexNoise Class Reference

#include <SimplexNoise.hpp>

Inheritance diagram for Ocular::Math::Noise::SimplexNoise:
Ocular::Math::Noise::ANoise

Public Member Functions

virtual float getValue (float const x, float const y)
 
virtual float getValue (float const x, float const y, float const z)
 
void setOctaves (uint32_t const octaves)
 
void setPersistence (float const persistence)
 
void setScale (float const scale)
 
- Public Member Functions inherited from Ocular::Math::Noise::ANoise
virtual float getValue (float const x)
 

Protected Member Functions

float getRawNoise (float const x, float const y)
 
float getRawNoise (float const x, float const y, float const z)
 

Detailed Description

Simplex Noise is an n-dimensional noise function that produces results comparable to the class Perlin Noise, but has less computational overhead.

Originally designed by Ken Perlin (2001), this implementation is adapted from the work done by Stefan Gustavson.

Though there is no seeding of Simplex Noise like with PRNGs, once can achieve a similar 'randomized' result by applying an offset to the provided x/y/z parameters. For example:

int32_t seed = prng->next(0, 1000);

for(uint32_t y = 0; y < 5; y++)
{
    for(uint32_t x = 0; x < 5; x++)
    {
        float value = noise->getValue((x + seed), (y + seed));
    }
}

Just remember that this is a fake randomization. The value at (0,0) will always be the same throughout all runs.

Ken Perlin: Making Noise http://www.noisemachine.com/talk1/32.html

Stefan Gustavson: Simplex Noise Demystified http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf

Member Function Documentation

float Ocular::Math::Noise::SimplexNoise::getValue ( float const  x,
float const  y 
)
virtual

Returns the noise value at the specified 2D coordinates.

Note: To get the raw noise value (without octaves, etc.) set the octaves, scale, and persistence all to 1.

Parameters
[in]x
[in]y
Returns
Value on range [-1.0, 1.0]

Reimplemented from Ocular::Math::Noise::ANoise.

float Ocular::Math::Noise::SimplexNoise::getValue ( float const  x,
float const  y,
float const  z 
)
virtual

Returns the noise value at the specified 3D coordinates.

Note: To get the raw noise value (without octaves, etc.) set the octaves, scale, and persistence all to 1.

Parameters
[in]x
[in]y
[in]z
Returns
Value on range [-1.0, 1.0]

Reimplemented from Ocular::Math::Noise::ANoise.

void Ocular::Math::Noise::SimplexNoise::setOctaves ( uint32_t const  octaves)

Sets the number of octaves to apply when generating noise values.

For each octave, a higher frequency/lower amplitude function will be added to the original. Additional octaves increase the amount of time required to generate the final value, but increases the definition.

Parameters
octavesNumber of octaves to apply (sane values are 0 to 15) (default 6)
void Ocular::Math::Noise::SimplexNoise::setPersistence ( float const  persistence)

Sets the persistence value for applied octaves.

The higher the persistence, the more of each succeeding octave will be added to the original. Very high persistence values can lead to output the resembles raw noise.

Parameters
[in]persistencePersistence value 0.0, 1.0
void Ocular::Math::Noise::SimplexNoise::setScale ( float const  scale)

Sets the scale of the noise generator.

Scale can be thought of as a zoom-level. The lower the scale, the closer in the zoom and vice versa.

Extremely low values can result in a blobby or solid output. Extremely high values can result in output that resembles raw noise.

Parameters
[in]scaleScale value (sane values are 0.0001 to 1.0) (default 0.01)

The documentation for this class was generated from the following files: