ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
SimplexNoise< colors > Class Template Reference

A material class for rendering Simplex Noise. More...

#include <SimplexNoise.h>

Inheritance diagram for SimplexNoise< colors >:
Collaboration diagram for SimplexNoise< colors >:

Public Member Functions

 SimplexNoise (int seed, GradientMaterial< colors > *gradientMaterial)
 Constructs a SimplexNoise instance.
 
float Noise (float xin, float yin)
 Generates 2D Simplex Noise.
 
float Noise (float xin, float yin, float zin)
 Generates 3D Simplex Noise.
 
void SetScale (Vector3D noiseScale)
 Sets the scale for noise generation.
 
void SetZPosition (float zPosition)
 Sets the Z-position for 3D noise generation.
 
RGBColor GetRGB (const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
 Retrieves the color for a given position based on the noise value.
 
- Public Member Functions inherited from Material
virtual ~Material ()=default
 Virtual destructor for proper cleanup in derived classes.
 

Private Member Functions

void InitializePermutation (int seed)
 Initializes the permutation tables based on the seed.
 

Private Attributes

GradientMaterial< colors > * gradientMaterial
 GradientMaterial used to map noise values to colors.
 
Vector3D noiseScale = Vector3D(1, 1, 1)
 Scaling factor for the noise generation.
 
const float F2 = 0.5f * (sqrtf(3.0f) - 1.0f)
 Simplex Noise constants for 2D.
 
const float G2 = (3.0f - sqrtf(3.0f)) / 6.0f
 Simplex Noise constants for 2D.
 
const float F3 = 1.0f / 3.0f
 Simplex Noise constants for 3D.
 
const float G3 = 1.0f / 6.0f
 Simplex Noise constants for 3D.
 
float zPosition = 0.0f
 Z-position for 3D noise.
 
Vector3D grad3 [12]
 
uint8_t p_supply [256]
 
uint8_t p [256]
 
uint8_t perm [512]
 Permutation table for noise generation.
 
uint8_t permMod12 [512]
 Permutation table modulo 12 for gradient selection.
 

Additional Inherited Members

- Public Types inherited from Material
enum  Method {
  Base , Add , Subtract , Multiply ,
  Divide , Darken , Lighten , Screen ,
  Overlay , SoftLight , Replace , EfficientMask ,
  Bypass
}
 Defines blending methods for combining colors. More...
 

Detailed Description

template<size_t colors>
class SimplexNoise< colors >

A material class for rendering Simplex Noise.

This template-based class generates noise values using the Simplex Noise algorithm and maps the values to colors using a GradientMaterial.

Template Parameters
colorsThe number of colors in the gradient material.

Definition at line 30 of file SimplexNoise.h.

Constructor & Destructor Documentation

◆ SimplexNoise()

template<size_t colors>
SimplexNoise ( int  seed,
GradientMaterial< colors > *  gradientMaterial 
)

Constructs a SimplexNoise instance.

Parameters
seedThe seed for noise generation.
gradientMaterialPointer to a GradientMaterial for mapping noise to colors.

Member Function Documentation

◆ GetRGB()

template<size_t colors>
RGBColor GetRGB ( const Vector3D position,
const Vector3D normal,
const Vector3D uvw 
)
overridevirtual

Retrieves the color for a given position based on the noise value.

Parameters
position3D position in the scene.
normalNormal vector at the position (not used for this material).
uvwTexture coordinates at the position (not used for this material).
Returns
The RGB color corresponding to the noise value at the position.

Implements Material.

Referenced by FlowNoise::GetRGB(), RainbowNoise::GetRGB(), and RainbowNoise2::GetRGB().

◆ InitializePermutation()

template<size_t colors>
void InitializePermutation ( int  seed)
private

Initializes the permutation tables based on the seed.

Parameters
seedThe seed for randomizing the permutation tables.

◆ Noise() [1/2]

template<size_t colors>
float Noise ( float  xin,
float  yin 
)

Generates 2D Simplex Noise.

Parameters
xinX-coordinate.
yinY-coordinate.
Returns
The noise value at the given coordinates.

◆ Noise() [2/2]

template<size_t colors>
float Noise ( float  xin,
float  yin,
float  zin 
)

Generates 3D Simplex Noise.

Parameters
xinX-coordinate.
yinY-coordinate.
zinZ-coordinate.
Returns
The noise value at the given coordinates.

◆ SetScale()

template<size_t colors>
void SetScale ( Vector3D  noiseScale)

Sets the scale for noise generation.

Parameters
noiseScaleA Vector3D representing the scaling factors for X, Y, and Z.

Referenced by FlowNoise::Update(), RainbowNoise::Update(), RainbowNoise2::Update(), TVStatic::Update(), ProtogenArtleckAnimation::Update(), WaffleDaProtoAnimation::Update(), and NukudeFaceAnimation::Update().

◆ SetZPosition()

template<size_t colors>
void SetZPosition ( float  zPosition)

Sets the Z-position for 3D noise generation.

Parameters
zPositionThe Z-coordinate for noise generation.

Referenced by FlowNoise::Update(), RainbowNoise::Update(), RainbowNoise2::Update(), TVStatic::Update(), ProtogenArtleckAnimation::Update(), WaffleDaProtoAnimation::Update(), and NukudeFaceAnimation::Update().

Member Data Documentation

◆ F2

template<size_t colors>
const float F2 = 0.5f * (sqrtf(3.0f) - 1.0f)
private

Simplex Noise constants for 2D.

Definition at line 35 of file SimplexNoise.h.

◆ F3

template<size_t colors>
const float F3 = 1.0f / 3.0f
private

Simplex Noise constants for 3D.

Definition at line 37 of file SimplexNoise.h.

◆ G2

template<size_t colors>
const float G2 = (3.0f - sqrtf(3.0f)) / 6.0f
private

Simplex Noise constants for 2D.

Definition at line 36 of file SimplexNoise.h.

◆ G3

template<size_t colors>
const float G3 = 1.0f / 6.0f
private

Simplex Noise constants for 3D.

Definition at line 38 of file SimplexNoise.h.

◆ grad3

template<size_t colors>
Vector3D grad3[12]
private
Initial value:
= {Vector3D(1, 1, 0), Vector3D(-1, 1, 0), Vector3D(1, -1, 0), Vector3D(-1, -1, 0),
Vector3D(1, 0, 1), Vector3D(-1, 0, 1), Vector3D(1, 0, -1), Vector3D(-1, 0, -1),
Vector3D(0, 1, 1), Vector3D(0, -1, 1), Vector3D(0, 1, -1), Vector3D(0, -1, -1) }
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26

Definition at line 42 of file SimplexNoise.h.

◆ gradientMaterial

template<size_t colors>
GradientMaterial<colors>* gradientMaterial
private

GradientMaterial used to map noise values to colors.

Definition at line 32 of file SimplexNoise.h.

◆ noiseScale

template<size_t colors>
Vector3D noiseScale = Vector3D(1, 1, 1)
private

Scaling factor for the noise generation.

Definition at line 34 of file SimplexNoise.h.

◆ p

template<size_t colors>
uint8_t p[256]
private
Initial value:
= {151,160,137,91,90,15,
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180}

Definition at line 61 of file SimplexNoise.h.

◆ p_supply

template<size_t colors>
uint8_t p_supply[256]
private
Initial value:
= {151,160,137,91,90,15,
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180}

Definition at line 47 of file SimplexNoise.h.

◆ perm

template<size_t colors>
uint8_t perm[512]
private

Permutation table for noise generation.

Definition at line 76 of file SimplexNoise.h.

◆ permMod12

template<size_t colors>
uint8_t permMod12[512]
private

Permutation table modulo 12 for gradient selection.

Definition at line 77 of file SimplexNoise.h.

◆ zPosition

template<size_t colors>
float zPosition = 0.0f
private

Z-position for 3D noise.

Definition at line 39 of file SimplexNoise.h.


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