NoiseInterface Class Reference

#include <noise.h>

Public Member Functions

MAXON_METHOD Result< void > Init (UInt32 seed, Int permutationTablePower)
 
MAXON_METHOD UInt32 GetSeed () const
 
MAXON_METHOD Int GetPermutationTablePower () const
 
MAXON_METHOD const BaseArray< UInt16 > * GetPermutationTable () const
 
MAXON_METHOD Result< void > GetGradientTable (Bool gradient3D, BaseArray< Vector4d32 > &gradient) const
 
MAXON_METHOD Result< void > GetFbmTable (FbmTableRef table, BaseArray< Float32 > &fbm) const
 
MAXON_METHOD const BaseArray< Vector4d32 > * GetRandomTable () const
 
MAXON_METHOD Float32 SNoise (const Vector32 &p) const
 
MAXON_METHOD Float32 SNoise (const Vector4d32 &p) const
 
MAXON_FUNCTION Float32 SNoise (const Vector32 &p, Float32 time) const
 
MAXON_METHOD Float32 PeriodicSNoise (const Vector32 &p, Int repeatX, Int repeatY, Int repeatZ) const
 
MAXON_METHOD Float32 PeriodicSNoise (const Vector4d32 &p, Int repeatX, Int repeatY, Int repeatZ, Int repeatT) const
 
MAXON_METHOD void Voronoi (const Vector32 &p, Int maximumOrder, Float32 *distance, Int32 *index) const
 
MAXON_METHOD void Voronoi (const Vector4d32 &p, Int maximumOrder, Float32 *distance, Int32 *index) const
 
MAXON_METHOD ResultMemT< FbmTableRefInitFbm (Float32 lacunarity, Float32 gain) const
 
MAXON_METHOD Float32 Fbm (FbmTableRef table, Vector32 p, Float32 octaves) const
 
MAXON_METHOD Float32 Fbm (FbmTableRef table, Vector4d32 p, Float32 octaves) const
 
MAXON_METHOD Float32 Turbulence (Vector32 p, Float32 octaves, Bool absolute) const
 
MAXON_METHOD Float32 Turbulence (Vector4d32 p, Float32 octaves, Bool absolute) const
 
MAXON_METHOD Float32 RidgedMultifractal (FbmTableRef table, Vector32 p, Float32 octaves, Float32 offset, Float32 threshold) const
 
MAXON_METHOD Float32 RidgedMultifractal (FbmTableRef table, Vector4d32 p, Float32 octaves, Float32 offset, Float32 threshold) const
 

Static Public Member Functions

static MAXON_METHOD NoiseInterfaceAlloc (MAXON_SOURCE_LOCATION_DECLARATION)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (NoiseInterface, MAXON_REFERENCE_NORMAL, "net.maxon.render.interface.noise")
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( NoiseInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.render.interface.noise"   
)
private

◆ Alloc()

allocator for common use.

◆ Init()

MAXON_METHOD Result<void> Init ( UInt32  seed,
Int  permutationTablePower 
)

Initializes the noise. A permutationTablePower of 10 results in 1024 elements, which is a good compromise between too frequent repetition and memory consumption.

Parameters
[in]seedStart value for the random table generation.
[in]permutationTablePowerThis specifies the size of the permutation table, which will have (2 ^ permutationTablePower) entries. permutationTablePower must be [5..16], otherwise initialization fails.
Returns
OK on success. IllegalArgumentError is returned if the permutationTablePower was out of range.

◆ GetSeed()

MAXON_METHOD UInt32 GetSeed ( ) const

Returns the seed value the noise was initialized with.

Returns
Seed value of that was passed to Init() or 0 if noise was not initialized.

◆ GetPermutationTablePower()

MAXON_METHOD Int GetPermutationTablePower ( ) const

Returns the power of the permutation table the noise was initialized with.

Returns
Value that was passed to Init() or 0 if noise was not initialized.

◆ GetPermutationTable()

MAXON_METHOD const BaseArray<UInt16>* GetPermutationTable ( ) const

Returns a pointer to the permutation table. The table is only valid as long as the class exists and no further Init() is called. All values are read-only. The permutation table has at least (1 << permutationTablePower) entries. Any additional entries are repetitions of the original elements.

Returns
The permutation table or nullptr if noise was not initialized. Ownership doesn't change - the table is still owned by the NoiseRef class.

◆ GetGradientTable()

MAXON_METHOD Result<void> GetGradientTable ( Bool  gradient3D,
BaseArray< Vector4d32 > &  gradient 
) const

Fills an array with the gradient data.

Parameters
[in]gradient3DIf this parameter is true, the table for the 3D gradient is returned, otherwise a 4D gradient is returned.
[in]gradientThe gradient array to fill.
Returns
OK on success.

◆ GetFbmTable()

MAXON_METHOD Result<void> GetFbmTable ( FbmTableRef  table,
BaseArray< Float32 > &  fbm 
) const

Fills an array with the FBM data. The table must have been initialized with InitFbm, otherwise the function will fail.

Parameters
[in]tableTable that was initialized with InitFbm.
[in]fbmThe table array to fill.
Returns
OK on success.

◆ GetRandomTable()

MAXON_METHOD const BaseArray<Vector4d32>* GetRandomTable ( ) const

Returns a pointer to the random point table. Each component of each point is in the range of [0..1]. The table is only valid as long as the class exists and no further Init() is called. All values are read-only. The random table has at least (1 << permutationTablePower) entries. Any additional entries are repetitions of the original elements.

Returns
The random table or nullptr if noise was not initialized. Ownership doesn't change - the table is still owned by the NoiseRef class.

◆ SNoise() [1/3]

MAXON_METHOD Float32 SNoise ( const Vector32 p) const

Calculates an 'Improved Perlin Noise' value for three dimensions. The noise will repeat itself after a distance of (1 << permutationTablePower). Note that calling with Vector4d32 and the fourth (w) component set to zero delivers different results as the 4-dimensional tables are different.

Parameters
[in]pPoint for noise calculation.
Returns
Noise value in the range of [-1..1]

◆ SNoise() [2/3]

MAXON_METHOD Float32 SNoise ( const Vector4d32 p) const

Calculates an 'Improved Perlin Noise' value for four dimensions. The noise will repeat itself after a distance of (1 << permutationTablePower).

Parameters
[in]pPoint for noise calculation.
Returns
Noise value in the range of [-1..1]

◆ SNoise() [3/3]

MAXON_FUNCTION Float32 SNoise ( const Vector32 p,
Float32  time 
) const

Calculates an 'Improved Perlin Noise' value for four dimensions. The noise will repeat itself after a distance of (1 << permutationTablePower). This is a convenience function that assigns the time to the fourth (w) component.

Parameters
[in]pPoint for noise calculation.
[in]timeTime (fourth dimension) for noise calculation.
Returns
Noise value in the range of [-1..1]

◆ PeriodicSNoise() [1/2]

MAXON_METHOD Float32 PeriodicSNoise ( const Vector32 p,
Int  repeatX,
Int  repeatY,
Int  repeatZ 
) const

Calculates a periodic 'Improved Perlin Noise' value for three dimensions. The noise will repeat itself after a distance of repeatX/repeatY/repeatZ. Note that calling with Vector4d32 and the fourth (w) component set to zero delivers different results as the 4-dimensional tables are different. Periodic noise is more than 2x slower than regular noise. If you have repetitions that are a power of 2 use a noise with fitting permutationTable instead.

Parameters
[in]pPoint for noise calculation.
[in]repeatXX repetition. Needs to be in the range of [2..(1 << permutationTablePower)].
[in]repeatYY repetition. Needs to be in the range of [2..(1 << permutationTablePower)].
[in]repeatZZ repetition. Needs to be in the range of [2..(1 << permutationTablePower)].
Returns
Noise value in the range of [-1..1]

◆ PeriodicSNoise() [2/2]

MAXON_METHOD Float32 PeriodicSNoise ( const Vector4d32 p,
Int  repeatX,
Int  repeatY,
Int  repeatZ,
Int  repeatT 
) const

Calculates a periodic 'Improved Perlin Noise' value for four dimensions. The noise will repeat itself after a distance of repeatX/repeatY/repeatZ/repeatT. Periodic noise is more than 2x slower than regular noise. If you have repetitions that are a power of 2 use a noise with fitting permutationTable instead.

Parameters
[in]pPoint for noise calculation.
[in]repeatXX repetition. Needs to be in the range of [2..(1 << permutationTablePower)].
[in]repeatYY repetition. Needs to be in the range of [2..(1 << permutationTablePower)].
[in]repeatZZ repetition. Needs to be in the range of [2..(1 << permutationTablePower)].
[in]repeatTT repetition. Needs to be in the range of [2..(1 << permutationTablePower)].
Returns
Noise value in the range of [-1..1]

◆ Voronoi() [1/2]

MAXON_METHOD void Voronoi ( const Vector32 p,
Int  maximumOrder,
Float32 distance,
Int32 index 
) const

Calculates voronoi noise for three dimensions. The noise will repeat itself after a distance of (1 << permutationTablePower). Make sure to choose maximumOrder as small as possible to optimize speed. Also passing nullptr for index will increase calculation speed. Note that calling with Vector4d32 and the fourth (w) component set to zero delivers different results as the 4-dimensional tables are different.

Parameters
[in]pPoint for noise calculation.
[in]maximumOrderMaximum order that will be calculated. This value must be in the range [1..3], otherwise undefined behaviour will happen.
[out]distancePointer to an array that will be filled with distance values. It is guaranteed that distance[i] <= distance[i + 1]. The array must at least have maximumOrder elements, otherwise the routine will crash.
[out]indexNullptr or pointer to an array that will be filled with indices to the noise permutation table that correspond to the distance values. The array must at least have maximumOrder elements, otherwise the routine will crash.

◆ Voronoi() [2/2]

MAXON_METHOD void Voronoi ( const Vector4d32 p,
Int  maximumOrder,
Float32 distance,
Int32 index 
) const

Calculates voronoi noise for four dimensions. The noise will repeat itself after a distance of (1 << permutationTablePower). Make sure to choose maximumOrder as small as possible to optimize speed. Also passing nullptr for index will increase calculation speed.

Parameters
[in]pPoint for noise calculation.
[in]maximumOrderMaximum order that will be calculated. This value must be in the range [1..3], otherwise undefined behaviour will happen.
[out]distancePointer to an array that will be filled with distance values. It is guaranteed that distance[i] <= distance[i + 1]. The array must at least have maximumOrder elements, otherwise the routine will crash.
[out]indexNullptr or pointer to an array that will be filled with indices to the noise permutation table that correspond to the distance values. The array must at least have maximumOrder elements, otherwise the routine will crash.

◆ InitFbm()

MAXON_METHOD ResultMemT<FbmTableRef> InitFbm ( Float32  lacunarity,
Float32  gain 
) const

Initializes the Fractal Brownian Motion coefficients. The standard is lacunarity 2.0 and gain 0.5. http://code.google.com/p/fractalterraingeneration/wiki/Fractional_Brownian_Motion.

Parameters
[in]lacunarityFrequency multiplier between successive octaves, must be >0.0. A lacunarity of 2.0 means that the frequency doubles each octave.
[in]gainValue that shrinks the amplitude. Each octave the amplitude is multiplied by the gain. Values need to be >0.0.
Returns
Reference to precomputed Fbm coefficients or nullptr if not enough memory.

◆ Fbm() [1/2]

MAXON_METHOD Float32 Fbm ( FbmTableRef  table,
Vector32  p,
Float32  octaves 
) const

Calculates Fractal Brownian Motion noise.

Parameters
[in]tableTable that was initialized with InitFbm.
[in]pPoint for noise calculation.
[in]octavesNumber of octaves to be calculated in the range of [0..15]. The higher the number, the more computationally expensive the function.
Returns
Noise value. The range dependens on the values passed to InitFbm.

◆ Fbm() [2/2]

MAXON_METHOD Float32 Fbm ( FbmTableRef  table,
Vector4d32  p,
Float32  octaves 
) const

Calculates Fractal Brownian Motion noise. Note that calling with Vector4d32 and the fourth (w) component set to zero delivers different results as the 4-dimensional tables are different.

Parameters
[in]tableTable that was initialized with InitFbm.
[in]pPoint for noise calculation.
[in]octavesNumber of octaves to be calculated in the range of [0..15]. The higher the number, the more computationally expensive the function.
Returns
Noise value. The range dependens on the values passed to InitFbm.

◆ Turbulence() [1/2]

MAXON_METHOD Float32 Turbulence ( Vector32  p,
Float32  octaves,
Bool  absolute 
) const

Calculates Perlin's Turbulence function. Note that calling with Vector4d32 and the fourth (w) component set to zero delivers different results as the 4-dimensional tables are different.

Parameters
[in]pPoint for noise calculation.
[in]octavesNumber of octaves to be calculated. The higher the number, the more computationally expensive the function.
[in]absoluteIf true the absolute values of each octave are summed.
Returns
Turbulence value, in the range of [-1.75..1.75]

◆ Turbulence() [2/2]

MAXON_METHOD Float32 Turbulence ( Vector4d32  p,
Float32  octaves,
Bool  absolute 
) const

Calculates Perlin's Turbulence function.

Parameters
[in]pPoint for noise calculation.
[in]octavesNumber of octaves to be calculated. The higher the number, the more computationally expensive the function.
[in]absoluteIf true the absolute values of each octave are summed.
Returns
Turbulence value, in the range of [-1.75..1.75]

◆ RidgedMultifractal() [1/2]

MAXON_METHOD Float32 RidgedMultifractal ( FbmTableRef  table,
Vector32  p,
Float32  octaves,
Float32  offset,
Float32  threshold 
) const

Calculates Musgraves Ridged Multifractal function. Note that calling with Vector4d32 and the fourth (w) component set to zero delivers different results as the 4-dimensional tables are different.

Parameters
[in]tableTable that was initialized with InitFbm.
[in]pPoint for noise calculation.
[in]octavesNumber of octaves to be calculated. The higher the number, the more computationally expensive the function.
[in]offsetMust be >0.0. Offset where the details begin to ramp sharply. A good start value is 1.0.
[in]thresholdMust be >0.0. The higher the value, the more sharp details / peaks. A good start value is 2.0.
Returns
Multifractal value. The range depends on the used parameters.

◆ RidgedMultifractal() [2/2]

MAXON_METHOD Float32 RidgedMultifractal ( FbmTableRef  table,
Vector4d32  p,
Float32  octaves,
Float32  offset,
Float32  threshold 
) const

Calculates Musgraves Ridged Multifractal function.

Parameters
[in]tableTable that was initialized with InitFbm.
[in]pPoint for noise calculation.
[in]octavesNumber of octaves to be calculated. The higher the number, the more computationally expensive the function.
[in]offsetMust be >0.0. Offset where the details begin to ramp sharply. A good start value is 1.0.
[in]thresholdMust be >0.0. The higher the value, the more sharp details / peaks. A good start value is 2.0.
Returns
Multifractal value. The range depends on the used parameters.