Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Helpers.Computative.Algorithms.Simplex Class Reference

Simplex noise Implementation from Stefan Gustavson, optimized by Peter Eastman, ported to C#/optimized by Chris LaPointe More...

Inheritance diagram for pluginbase.Helpers.Computative.Algorithms.Simplex:
pluginbase.Helpers.Computative.ValuePoint3D

Public Member Functions

 Simplex (IPseudoRandom provider, int frequency, int octaves, float gain=0.65f, float lacunarity=2f)
 Initializes a new instance of the pluginbase.Helpers.Computative.Algorithms.Simplex class. More...
 
 Simplex (int seed, int frequency, int octaves, float gain=0.65f, float lacunarity=2f)
 Initializes a new instance of the pluginbase.Helpers.Computative.Algorithms.Simplex class. More...
 
override float GetValue (int x, int y, int z)
 NOTICE: Due to patent on 3d versions of simplex, it is not included in this implementation More...
 
override float GetValue (int x, int y)
 Get a value at an x,y coordinate More...
 
- Public Member Functions inherited from pluginbase.Helpers.Computative.ValuePoint3D
ValuePoint3D Mix (ValuePoint3D with, float sourceOpacity)
 Mix this value with another one at a certain ratio More...
 
ValuePoint3D Lighten (ValuePoint3D with)
 Lighten this value by another one More...
 
ValuePoint3D Darken (ValuePoint3D with)
 Darken this value by another one More...
 
ValuePoint3D CustomCombine (ValuePoint3D with, Combiner3D.CombinerOperator func)
 Combine two values using a custom combiner More...
 
ValuePoint3D CustomManipulator (Manip3D.ManipOperator func)
 Manipulate this value with a custom manipulator More...
 
ValuePoint3D Abs ()
 Absolute value More...
 
ValuePoint3D Invert ()
 Invert the value from a 0-1 range More...
 
ValuePoint3D Brightness (float amount)
 Adjust brightness. Takes in -1 to 1f More...
 
ValuePoint3D Contrast (float amount)
 Adjusts contract from -1 to 1 More...
 
ValuePoint3D Scale (float factor)
 Scale the specified factor and clamp More...
 
ValuePoint3D LinearBounds (float min, float max)
 Linearly interpolates to squish between the bounds More...
 
ValuePoint3D Threshold (float threshold)
 Threshold the specified threshold. Returns 0 if below, otherwise 1f More...
 
ValuePoint3D Gamma (float gamma)
 Gamma the specified gamma. Range 0f - 2f More...
 
ValuePoint3D Clamp ()
 Clamp this value between 0 and 1 More...
 
ValuePoint3D Clamp (float min, float max)
 Clamp this value between a min and max More...
 

Additional Inherited Members

- Static Public Member Functions inherited from pluginbase.Helpers.Computative.ValuePoint3D
static ValuePoint3D operator+ (ValuePoint3D a, ValuePoint3D b)
 Add two value points together More...
 
static ValuePoint3D operator- (ValuePoint3D a, ValuePoint3D b)
 Subtract two value points More...
 
static ValuePoint3D operator* (ValuePoint3D a, ValuePoint3D b)
 Multiply two value points More...
 
static ValuePoint3D operator/ (ValuePoint3D a, ValuePoint3D b)
 Divide one value by another More...
 

Detailed Description

Simplex noise Implementation from Stefan Gustavson, optimized by Peter Eastman, ported to C#/optimized by Chris LaPointe

Constructor & Destructor Documentation

pluginbase.Helpers.Computative.Algorithms.Simplex.Simplex ( IPseudoRandom  provider,
int  frequency,
int  octaves,
float  gain = 0.65f,
float  lacunarity = 2f 
)

Initializes a new instance of the pluginbase.Helpers.Computative.Algorithms.Simplex class.

Parameters
providerProvider.
frequencyFrequency.
octavesOctaves.
gainGain.
lacunarityLacunarity.

Attribute: ] tempPerm = new short[256

;

Attribute: i

= (short)i;

Attribute: idx], ref tempPerm[jdx

);

Attribute: i] = tempPerm[i & 255

;

Attribute: i] = (short)(_perm[i

% 12);

Attribute: octaves

;

Attribute: octaves

;

Attribute: i

= currFreq;

Attribute: i

= currAmpl / amplitudeSum;

84  {
85  _octaves = octaves;
86  _frequency = 1.0f / (float)frequency;
87  _gain = gain;
88  _lacunarity = lacunarity;
89 
90  //Setup the permutation based on the random provider
91  _random = new Random3D(provider);
92  short[] tempPerm = new short[256];
93  for (int i=0; i<256; ++i)
94  {
95  tempPerm[i] = (short)i;
96  }
97  for (int i=0; i<256; ++i)
98  {
99  int idx = _random.Randi(i, 0, 255);
100  int jdx = _random.Randi(i + 256, 0, 255);
101  swap(ref tempPerm[idx], ref tempPerm[jdx]);
102  }
103 
104  for (int i=0; i<512; ++i)
105  {
106  _perm[i] = tempPerm[i & 255];
107  _permMod12[i] = (short)(_perm[i] % 12);
108  }
109 
110  //Pre-compute the multiplier tables
111  float amplitudeSum = (1.0f - (float)Math.Pow(gain, octaves)) / (1.0f - gain);
112  _frequencyTable = new float[octaves];
113  _amplitudeTable = new float[octaves];
114 
115  float currFreq = _frequency;
116  float currAmpl = 1f;
117  for (int i=0; i<octaves; ++i)
118  {
119  _frequencyTable[i] = currFreq;
120  _amplitudeTable[i] = currAmpl / amplitudeSum;
121  currAmpl *= _gain;
122  currFreq *= _lacunarity;
123  }
124  }
A value instance of pure random numbers
Definition: Random3D.cs:9
int Randi(int x, int min, int max)
Returns int between (min, max)
Definition: Random3D.cs:99
pluginbase.Helpers.Computative.Algorithms.Simplex.Simplex ( int  seed,
int  frequency,
int  octaves,
float  gain = 0.65f,
float  lacunarity = 2f 
)

Initializes a new instance of the pluginbase.Helpers.Computative.Algorithms.Simplex class.

Parameters
seedSeed.
frequencyFrequency.
octavesOctaves.
gainGain.
lacunarityLacunarity.
135  :this(new PseudoRandom(seed), frequency, octaves, gain, lacunarity)
136  {
137  }
A basic implementation of a random number generator
Definition: PseudoRandom.cs:7

Member Function Documentation

override float pluginbase.Helpers.Computative.Algorithms.Simplex.GetValue ( int  x,
int  y,
int  z 
)
virtual

NOTICE: Due to patent on 3d versions of simplex, it is not included in this implementation

Returns
The value.
Parameters
xThe x coordinate.
yThe y coordinate.
zThe z coordinate.

Implements pluginbase.Helpers.Computative.ValuePoint3D.

233  {
234  /*float sum = 0f;
235  float freq;
236  for (int k = 0; k < _octaves; ++k)
237  {
238  freq = _frequencyTable[k];
239  sum += GetSimplex(x * freq, y * freq, z * freq) * _amplitudeTable[k];
240  }
241  return sum;*/
242  return 0f;
243  }
override float pluginbase.Helpers.Computative.Algorithms.Simplex.GetValue ( int  x,
int  y 
)
virtual

Get a value at an x,y coordinate

Returns
The value.
Parameters
xThe x coordinate.
yThe y coordinate.

Attribute: k

;

Attribute: k

;

Implements pluginbase.Helpers.Computative.ValuePoint3D.

319  {
320  float sum = 0f;
321  float freq;
322  for (int k = 0; k < _octaves; ++k)
323  {
324  freq = _frequencyTable[k];
325  sum += GetSimplex(x * freq, y * freq) * _amplitudeTable[k];
326  }
327  return sum;
328  }

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