C4DNoise Class Reference

#include <lib_noise.h>

Detailed Description

The noise class used for the Cinema 4D shaders.

Private Member Functions

 C4DNoise ()
 
 ~C4DNoise ()
 

Alloc/Free

static C4DNoiseAlloc (Int32 seed)
 
static C4DNoiseAlloc2 (Int32 seed)
 
static void Free (C4DNoise *&p)
 

Menu Container

static BaseContainer CreateMenuContainer (Bool bIncludeNone=false)
 

Has Octaves/Absolute/Cycles

static Bool HasOctaves (NoiseType t)
 
static Bool HasAbsolute (NoiseType t)
 
static Bool HasCycles (NoiseType t)
 

Miscellaneous

static void EvaluateSampleOffset (NoiseType type, Float rOctaves, Float rDelta, Float &rSampleOffset)
 
static void GetNoisePreview (NoiseType t, IconData &dat, String *str=nullptr)
 

Private

static const UCharGetPermutationTable ()
 
const FloatGetFBMTable ()
 
const FloatGetValueTable ()
 
const FloatGetImpulseTable ()
 
const Int32GetTPPermutationTable ()
 
const NoiseGradient * GetNoiseGradient ()
 
const Int32GetPermutationTableA ()
 

Noise

Float Noise (NoiseType t, Bool two_d, const Vector &p, Float time=0.0, Float octaves=4.0, Bool absolute=false, Float sampleRad=0.25, Float detailAtt=0.25, Int32 t_repeat=0)
 

Init Fbm

Bool InitFbm (Int32 lMaxOctaves, Float rLacunarity, Float h)
 

SNoise

Float SNoise (Vector p)
 
Float SNoise (Vector p, Float t, Int32 lRepeat)
 

Turbulence

Float Turbulence (Vector p, Float t, Float rOctaves, Bool bAbsolute, Int32 lRepeat)
 

Fbm/Multifractal

Float Fbm (Vector p, Float t, Float rOctaves, Int32 lRepeat)
 
Float RidgedMultifractal (Vector p, Float t, Float rOctaves, Float rOffset, Float rGain, Int32 lRepeat)
 

Constructor & Destructor Documentation

◆ C4DNoise()

C4DNoise ( )
private

◆ ~C4DNoise()

~C4DNoise ( )
private

Member Function Documentation

◆ Alloc()

static C4DNoise* Alloc ( Int32  seed)
static

Allocates a noise instance. Destroy the allocated noise instance with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in]seedThe noise seed.
Returns
The allocated noise instance, or nullptr if the allocation failed.

◆ Alloc2()

static C4DNoise* Alloc2 ( Int32  seed)
static

Allocates a noise instance. Destroy the allocated noise instance with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Note
This uses a different seed than Alloc() for the internal noises so that they look exactly like the old noises.
Parameters
[in]seedThe noise seed.
Returns
The allocated noise instance, or nullptr if the allocation failed.

◆ Free()

static void Free ( C4DNoise *&  p)
static

Destructs noise instances allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]pThe noise instance to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ CreateMenuContainer()

static BaseContainer CreateMenuContainer ( Bool  bIncludeNone = false)
static

Creates a menu container with the different noise options available.

Parameters
[in]bIncludeNonePass true to include the None option.
Returns
The generated noise menu. The NoiseType IDs are used.

◆ HasOctaves()

static Bool HasOctaves ( NoiseType  t)
static

Checks if a certain noise type supports the octaves parameter.

Parameters
[in]tThe noise type: NoiseType
Returns
true if octaves is supported, otherwise false.

◆ HasAbsolute()

static Bool HasAbsolute ( NoiseType  t)
static

Checks if a certain noise type supports the absolute parameter.

Parameters
[in]tThe noise type: NoiseType
Returns
true if absolute is supported, otherwise false.

◆ HasCycles()

static Bool HasCycles ( NoiseType  t)
static

Checks if a certain noise type supports the cycles parameter.

Parameters
[in]tThe noise type: NoiseType
Returns
true if cycles is supported, otherwise false.

◆ EvaluateSampleOffset()

static void EvaluateSampleOffset ( NoiseType  type,
Float  rOctaves,
Float  rDelta,
Float rSampleOffset 
)
static

Evaluates the sample offset.

Parameters
[in]typeThe noise type: NoiseType
[in]rOctavesThe number of octaves.
[in]rDeltaThe delta.
[out]rSampleOffsetAssigned the sample offset.

◆ GetNoisePreview()

static void GetNoisePreview ( NoiseType  t,
IconData dat,
String str = nullptr 
)
static

Generates a noise preview in dat.

Parameters
[in]tThe noise type: NoiseType
[out]datFilled with the noise preview.
[out]strIf not nullptr then the name of the noise is assigned. The caller owns the pointed string.

◆ Noise()

Float Noise ( NoiseType  t,
Bool  two_d,
const Vector p,
Float  time = 0.0,
Float  octaves = 4.0,
Bool  absolute = false,
Float  sampleRad = 0.25,
Float  detailAtt = 0.25,
Int32  t_repeat = 0 
)

Samples a 2D or 3D noise.

Parameters
[in]tThe noise type: NoiseType
[in]two_dtrue for 2D sampling, false for 3D sampling.
[in]pThe position.
[in]timeThe time.
[in]octavesThe number of octaves.
[in]absolutetrue to return an absolute value.
[in]sampleRadThe sample radius.
[in]detailAttThe detail attenuation.
[in]t_repeatMust be 2^x - 1, where x = [1..10], i.e. one of 1, 3, 7, 15, 31, 63, 127, 255, 511, and 1023.
A noise repeats itself in time every 1024 units. Using a smaller t_repeat the noise will repeat at an earlier time.
Returns
The noise sample.

◆ InitFbm()

Bool InitFbm ( Int32  lMaxOctaves,
Float  rLacunarity,
Float  h 
)

Initializes Fractal Brownian Motion.

Parameters
[in]lMaxOctavesThe maximum number of octaves.
[in]rLacunarityThe lacunarity.
[in]hThe h parameter.
Returns
true if successful, otherwise false.

◆ GetFBMTable()

const Float* GetFBMTable ( )

Private.

◆ GetValueTable()

const Float* GetValueTable ( )

Private.

◆ GetImpulseTable()

const Float* GetImpulseTable ( )

Private.

◆ GetPermutationTable()

static const UChar* GetPermutationTable ( )
static

Private.

◆ GetTPPermutationTable()

const Int32* GetTPPermutationTable ( )

Private.

◆ GetNoiseGradient()

const NoiseGradient* GetNoiseGradient ( )

Private.

◆ GetPermutationTableA()

const Int32* GetPermutationTableA ( )

Private.

◆ SNoise() [1/2]

Float SNoise ( Vector  p)

Generates a signed noise value.

Parameters
[in]pThe noise coordinate.
Returns
A signed noise value, between -1.0 and 1.0.

◆ SNoise() [2/2]

Float SNoise ( Vector  p,
Float  t,
Int32  lRepeat 
)

Generates a periodic signed noise value.

Parameters
[in]pThe noise coordinate.
[in]tThe time.
[in]lRepeatMust be 2^x - 1, where x = [1..10], i.e. one of 1, 3, 7, 15, 31, 63, 127, 255, 511, and 1023.
A noise repeats itself in time every 1024 units. Using a smaller lRepeat the noise will repeat at an earlier time.
Returns
A signed noise value, between -1.0 and 1.0.

◆ Turbulence()

Float Turbulence ( Vector  p,
Float  t,
Float  rOctaves,
Bool  bAbsolute,
Int32  lRepeat 
)

Generates a periodic turbulence value, this is a sum of multiple noises with different frequency.

Parameters
[in]pThe noise coordinate.
[in]tThe time.
[in]rOctavesThe number of octaves.
[in]bAbsolutetrue to return an absolute value.
[in]lRepeatMust be 2^x - 1, where x = [1..10], i.e. one of 1, 3, 7, 15, 31, 63, 127, 255, 511, and 1023.
A noise repeats itself in time every 1024 units. Using a smaller lRepeat the noise will repeat at an earlier time.
Returns
A turbulence value, between -1.0 and 1.0 unless bAbsolute is true, in which case it will be between 0.0 to 1.0.

◆ Fbm()

Float Fbm ( Vector  p,
Float  t,
Float  rOctaves,
Int32  lRepeat 
)

Generates a periodic Fractional Brownian Motion value.

Note
Before using this function call InitFbm().
Parameters
[in]pThe noise coordinate.
[in]tThe time.
[in]rOctavesThe number of octaves. Must not exceed the value passed to InitFbm(), but can be lower.
[in]lRepeatMust be 2^x - 1, where x = [1..10], i.e. one of 1, 3, 7, 15, 31, 63, 127, 255, 511, and 1023.
A noise repeats itself in time every 1024 units. Using a smaller lRepeat the noise will repeat at an earlier time.
Returns
The Fbm value.

◆ RidgedMultifractal()

Float RidgedMultifractal ( Vector  p,
Float  t,
Float  rOctaves,
Float  rOffset,
Float  rGain,
Int32  lRepeat 
)

Generates a periodic fractal function used for such things as landscapes or mountain ranges.

Note
Before using this function call InitFbm().
Parameters
[in]pThe evaluation point.
[in]tThe time.
[in]rOctavesThe number of octaves. Must not exceed the value passed to InitFbm(), but can be lower.
[in]rOffsetThe zero offset, this controls the multifractality.
[in]rGainThe amplification of the fractal value.
[in]lRepeatMust be 2^x - 1, where x = [1..10], i.e. one of 1, 3, 7, 15, 31, 63, 127, 255, 511, and 1023.
A noise repeats itself in time every 1024 units. Using a smaller lRepeat the noise will repeat at an earlier time.
Returns
The fractal value.