Perlin noise function.

Namespace:  AForge.Math
Assembly:  AForge.Math (in AForge.Math.dll) Version: (


public class PerlinNoise


The class implements 1-D and 2-D Perlin noise functions, which represent sum of several smooth noise functions with different frequency and amplitude. The description of Perlin noise function and its calculation may be found on Hugo Elias's page.

The number of noise functions, which comprise the resulting Perlin noise function, is set by Octaves property. Amplitude and frequency values for each octave start from values, which are set by InitFrequency and InitAmplitude properties.

Sample usage (clouds effect):

// create Perlin noise function
PerlinNoise noise = new PerlinNoise( 8, 0.5, 1.0 / 32 );
// generate clouds effect
float[,] texture = new float[height, width];

for ( int y = 0; y < height; y++ )
    for ( int x = 0; x < width; x++ )
        texture[y, x] = 
            Math.Max( 0.0f, Math.Min( 1.0f,
                (float) noise.Function2D( x, y ) * 0.5f + 0.5f
            ) );

Inheritance Hierarchy


See Also