OmegaEngine API  1.0.3
Public Member Functions | Properties | List of all members
OmegaEngine.PerlinNoise Class Reference

Perlin noise function. More...

Public Member Functions

 PerlinNoise ()
 Initializes a new instance of the PerlinNoise class. More...
 
double Function (double x)
 1-D Perlin noise function. More...
 
double Function2D (double x, double y)
 2-D Perlin noise function. More...
 

Properties

double InitFrequency [get, set]
 Initial frequency. More...
 
double InitAmplitude [get, set]
 Initial amplitude. More...
 
double Persistence [get, set]
 Persistence value. More...
 
int Octaves [get, set]
 Number of octaves, [1, 32]. More...
 

Detailed Description

Perlin noise function.

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
) );
}
}

Constructor & Destructor Documentation

◆ PerlinNoise()

OmegaEngine.PerlinNoise.PerlinNoise ( )
inline

Initializes a new instance of the PerlinNoise class.

Member Function Documentation

◆ Function()

double OmegaEngine.PerlinNoise.Function ( double  x)
inline

1-D Perlin noise function.

Parameters
xx value.
Returns
Returns function's value at point x .

◆ Function2D()

double OmegaEngine.PerlinNoise.Function2D ( double  x,
double  y 
)
inline

2-D Perlin noise function.

Parameters
xx value.
yy value.
Returns
Returns function's value at point (x , y ).

Property Documentation

◆ InitAmplitude

double OmegaEngine.PerlinNoise.InitAmplitude
getset

Initial amplitude.

The property sets initial amplitude of the first octave. Amplitudes for next octaves are calculated using the next equation:
amplitudei = InitAmplitude * Persistencei, where i = [0, Octaves).

Default value is set to 1.

◆ InitFrequency

double OmegaEngine.PerlinNoise.InitFrequency
getset

Initial frequency.

The property sets initial frequency of the first octave. Frequencies for next octaves are calculated using the next equation:
frequencyi = InitFrequency * 2i, where i = [0, Octaves).

Default value is set to 1.

◆ Octaves

int OmegaEngine.PerlinNoise.Octaves
getset

Number of octaves, [1, 32].

The property sets the number of noise functions, which sum up the resulting Perlin noise function.

Default value is set to 4.

◆ Persistence

double OmegaEngine.PerlinNoise.Persistence
getset

Persistence value.

The property sets so called persistence value, which controls the way how amplitude is calculated for each octave comprising the Perlin noise function.

Default value is set to 0.65.


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