Perlin

Noise module that outputs 3-dimensional Perlin noise.

@image html moduleperlin.png

Perlin noise is the sum of several coherent-noise functions of ever-increasing frequencies and ever-decreasing amplitudes.

An important property of Perlin noise is that a small change in the input value will produce a small change in the output value, while a large change in the input value will produce a random change in the output value.

This noise module outputs Perlin-noise values that usually range from -1.0 to +1.0, but there are no guarantees that all output values will exist within that range.

For a better description of Perlin noise, see the links in the <i>References and Acknowledgments</i> section.

This noise module does not require any source modules.

<b>Octaves</b>

The number of octaves control the <i>amount of detail</i> of the Perlin noise. Adding more octaves increases the detail of the Perlin noise, but with the drawback of increasing the calculation time.

An octave is one of the coherent-noise functions in a series of coherent-noise functions that are added together to form Perlin noise.

An application may specify the frequency of the first octave by calling the SetFrequency() method.

An application may specify the number of octaves that generate Perlin noise by calling the SetOctaveCount() method.

These coherent-noise functions are called octaves because each octave has, by default, double the frequency of the previous octave. Musical tones have this property as well; a musical C tone that is one octave higher than the previous C tone has double its frequency.

<b>Frequency</b>

An application may specify the frequency of the first octave by calling the SetFrequency() method.

<b>Persistence</b>

The persistence value controls the <i>roughness</i> of the Perlin noise. Larger values produce rougher noise.

The persistence value determines how quickly the amplitudes diminish for successive octaves. The amplitude of the first octave is 1.0. The amplitude of each subsequent octave is equal to the product of the previous octave's amplitude and the persistence value. So a persistence value of 0.5 sets the amplitude of the first octave to 1.0; the second, 0.5; the third, 0.25; etc.

An application may specify the persistence value by calling the SetPersistence() method.

<b>Lacunarity</b>

The lacunarity specifies the frequency multipler between successive octaves.

The effect of modifying the lacunarity is subtle; you may need to play with the lacunarity value to determine the effects. For best results, set the lacunarity to a number between 1.5 and 3.5.

<b>References &amp; acknowledgments</b>

<a href=http://www.noisemachine.com/talk1/>The Noise Machine</a> - From the master, Ken Perlin himself. This page contains a presentation that describes Perlin noise and some of its variants. He won an Oscar for creating the Perlin noise algorithm!

<a href=http://freespace.virgin.net/hugo.elias/models/m_perlin.htm> Perlin Noise</a> - Hugo Elias's webpage contains a very good description of Perlin noise and describes its many applications. This page gave me the inspiration to create libnoise in the first place. Now that I know how to generate Perlin noise, I will never again use cheesy subdivision algorithms to create terrain (unless I absolutely need the speed.)

<a href=http://www.robo-murito.net/code/perlin-noise-math-faq.html>The Perlin noise math FAQ</a> - A good page that describes Perlin noise in plain English with only a minor amount of math. During development of libnoise, I noticed that my coherent-noise function generated terrain with some "regularity" to the terrain features. This page describes a better coherent-noise function called <i>gradient noise</i>. This version of module::Perlin uses gradient coherent noise to generate Perlin noise.

Constructors

this
this()

Constructor.

Members

Functions

GetFrequency
double GetFrequency()

Returns the frequency of the first octave.

GetLacunarity
double GetLacunarity()

Returns the lacunarity of the Perlin noise.

GetNoiseQuality
NoiseQuality GetNoiseQuality()

Returns the quality of the Perlin noise.

GetOctaveCount
int GetOctaveCount()

Returns the number of octaves that generate the Perlin noise.

GetPersistence
double GetPersistence()

Returns the persistence value of the Perlin noise.

GetSeed
int GetSeed()

Returns the seed value used by the Perlin-noise function.

GetSourceModCount
int GetSourceModCount()
Undocumented in source. Be warned that the author may not have intended to support it.
GetValue
double GetValue(double x, double y, double z)
Undocumented in source. Be warned that the author may not have intended to support it.
SetFrequency
void SetFrequency(double frequency)

Sets the frequency of the first octave.

SetLacunarity
void SetLacunarity(double lacunarity)

Sets the lacunarity of the Perlin noise.

SetNoiseQuality
void SetNoiseQuality(NoiseQuality noiseQuality)

Sets the quality of the Perlin noise.

SetOctaveCount
void SetOctaveCount(int octaveCount)

Sets the number of octaves that generate the Perlin noise.

SetPersistence
void SetPersistence(double persistence)

Sets the persistence value of the Perlin noise.

SetSeed
void SetSeed(int seed)

Sets the seed value used by the Perlin-noise function.

Variables

m_frequency
double m_frequency;

Frequency of the first octave.

m_lacunarity
double m_lacunarity;

Frequency multiplier between successive octaves.

m_noiseQuality
NoiseQuality m_noiseQuality;

Quality of the Perlin noise.

m_octaveCount
int m_octaveCount;

Total number of octaves that generate the Perlin noise.

m_persistence
double m_persistence;

Persistence of the Perlin noise.

m_seed
int m_seed;

Seed value used by the Perlin-noise function.

Inherited Members

From Mod

~this
~this()

Destructor.

GetSourceMod
const(Mod) GetSourceMod(int index)

Returns a reference to a source module connected to this noise module.

GetSourceModCount
int GetSourceModCount()

Returns the number of source modules required by this noise module.

GetValue
double GetValue(double x, double y, double z)

Generates an output value given the coordinates of the specified input value.

SetSourceMod
void SetSourceMod(int index, const(Mod)* sourceMod)

Connects a source module to this noise module.

m_pSourceMod
const(Mod)*[] m_pSourceMod;

An array containing the pointers to each source module required by this noise module.

Meta