#include <PerlinNoiseAlgorithm.h>
PerlinNoiseAlgorithm::PerlinNoiseAlgorithm |
( |
int |
width, |
|
|
int |
height |
|
) |
| |
Initializes the attributes and generates the gradient and permutations tables.
- Parameters
-
[in] | width | Size of the terrain surface to generate in X-axis. |
[in] | height | Size of the terrain surface to generate in Y-axis. |
float * PerlinNoiseAlgorithm::GenerateCloudsTexture |
( |
std::size_t |
octaveCount, |
|
|
float |
persistence |
|
) |
| |
Generates multiple noise surfaces at different frequencies and sums them up together with different weights given by persistence. Deallocation of the noise surface is automatic after the instance is deleted. If the method is called repeatedly, previous result is rewritten. Less surfaces result in a rough terrain with a small elevation differences, more surfaces result in smoother terrain with higher elevation differences.
[Based] on a theory from Ken Perlin's talk which can be found at http://www.noisemachine.com/talk1/21.html , with some parts inspired by algorithm at http://devmag.org.za/2009/04/25/perlin-noise/ (e.g. faster squaring (<<) in case base is always 2)
- Parameters
-
[in] | octaveCount | Number of noise surfaces which are summed up together. |
[in] | persistence | Property similar to fractal dimension - the higher the persistence is, the more rough the terrain is and vice versa. |
- Returns
- Generated noise surface in one-dimensional array of size [width * height] if allocation succeded, NULL otherwise.
float * PerlinNoiseAlgorithm::GenerateNoiseTexture |
( |
float |
frequencyX, |
|
|
float |
frequencyY |
|
) |
| |
Generates a new single noise texture of a given dimensions with points sampled at given frequencies. Deallocation of the noise texture is user's resposibility.
- Parameters
-
[in] | frequencyX | Frequency at which is noise sampled in X-axis. |
[in] | frequencyY | Frequency at which is noise sampled in Y-axis. |
- Returns
- Pointer to the newly generated noise surface in one-dimensional array of size [width * height] if allocation succeded, NULL otherwise.
float PerlinNoiseAlgorithm::GetNoise |
( |
float |
x, |
|
|
float |
y |
|
) |
| |
Returns the value of perlin noise function in two dimensions for the point located at the given coordinates.
[Adapted], modified and clarified version of function noise2() from original implementation by Ken Perlin which can be found at http://www.mrl.nyu.edu/~perlin/doc/oscar.html#noise
- Parameters
-
[in] | x | Location of the point on the X-axis. |
[in] | y | Location of the point on the Y-axis. |
- Returns
- Intensity value of the perlin noise function for the point at the given two-dimensional coordinates.
The documentation for this class was generated from the following files: