Perlin noise function.

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

Syntax

C#
public class PerlinNoise

Remarks

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):

CopyC#
// 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

System..::.Object
  AForge.Math..::.PerlinNoise

See Also