Click or drag to resize
Accord.NET (logo)

PerlinNoise Class

Perlin noise function.
Inheritance Hierarchy
SystemObject
  Accord.MathPerlinNoise

Namespace:  Accord.Math
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax
public class PerlinNoise
Request Example View Source

The PerlinNoise type exposes the following members.

Constructors
  NameDescription
Public methodPerlinNoise
Initializes a new instance of the PerlinNoise class.
Public methodPerlinNoise(Int32, Double)
Initializes a new instance of the PerlinNoise class.
Public methodPerlinNoise(Int32, Double, Double, Double)
Initializes a new instance of the PerlinNoise class.
Top
Properties
  NameDescription
Public propertyInitAmplitude
Initial amplitude.
Public propertyInitFrequency
Initial frequency.
Public propertyOctaves
Number of octaves, [1, 32]. Default is 4.
Public propertyPersistence
Persistence value.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFunction
1-D Perlin noise function.
Public methodFunction2D
2-D Perlin noise function.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
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):

// 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
            ) );
    }
}
See Also