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

Perlin noise implementation More...

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

Public Member Functions

 Perlin (IPseudoRandom provider, int frequency, int levels)
 Initializes a perlin noise generator More...
 
 Perlin (int seed, int frequency, int levels)
 Initialize an instance of perlin noise More...
 
override float GetValue (int x, int y, int z)
 Get a value between 0-1 More...
 
override float GetValue (int x, int y)
 Get a 2D value between 0-1 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...
 

Public Attributes

readonly int Frequency
 Frequency of the perlin noise More...
 
readonly int Levels
 Number of levels incorporated into perlin noise 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

Perlin noise implementation

Constructor & Destructor Documentation

pluginbase.Helpers.Computative.Algorithms.Perlin.Perlin ( IPseudoRandom  provider,
int  frequency,
int  levels 
)

Initializes a perlin noise generator

Parameters
providerRandom Provider.
frequencyFrequency.
levelsLevels.

Attribute: levels

;

Attribute: levels

;

Attribute: level

= (int)(Frequency / (float)Math.Pow(2, level));

Attribute: level

= (1f / (float)Math.Pow(2, level)) / (float)maxWeight;

33  {
34  random = new Random3D(provider);
35  Frequency = frequency;
36  Levels = levels;
37 
38  double maxWeight = 2.0 * (1.0 - Math.Pow(0.5, levels)); //Sum of halves to determine max weight value to scale
39  _sizeTable = new int[levels];
40  _weightTable = new float[levels];
41  for (int level = 0; level < Levels; ++level)
42  {
43  _sizeTable[level] = (int)(Frequency / (float)Math.Pow(2, level));
44  _weightTable[level] = (1f / (float)Math.Pow(2, level)) / (float)maxWeight;
45  }
46  }
readonly int Levels
Number of levels incorporated into perlin noise
Definition: Perlin.cs:20
A value instance of pure random numbers
Definition: Random3D.cs:9
readonly int Frequency
Frequency of the perlin noise
Definition: Perlin.cs:15
pluginbase.Helpers.Computative.Algorithms.Perlin.Perlin ( int  seed,
int  frequency,
int  levels 
)

Initialize an instance of perlin noise

Parameters
seedSeed.
frequencyFrequency.
levelsLevels.
55  :this(new PseudoRandom(seed), frequency, levels)
56  {}
A basic implementation of a random number generator
Definition: PseudoRandom.cs:7

Member Function Documentation

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

Get a value between 0-1

Parameters
xA System.Int32
yA System.Int32
zA System.Int32
Returns
A System.Int32

Attribute: level

;

Attribute: level

;

Implements pluginbase.Helpers.Computative.ValuePoint3D.

74  {
75  int levelSize;
76  int bX, bY, bZ;
77  float dX, dY, dZ;
78  float val = 0f;
79  for (int level = 0; level < Levels; ++level)
80  {
81  levelSize = _sizeTable[level];
82  if (levelSize <= 0){
83  break;
84  }
85 
86  bX = x - MExt.mmod(x, levelSize);
87  bY = y - MExt.mmod(y, levelSize);
88  bZ = z - MExt.mmod(z, levelSize);
89 
90  dX = (x - bX) / (float)levelSize;
91  dY = (y - bY) / (float)levelSize;
92  dZ = (z - bZ) / (float)levelSize;
93 
94  val += (
95  ((random.Rand(bX, bY, bZ) * (1f - dX) + random.Rand(bX + levelSize, bY, bZ) * dX) * (1f - dY)
96  + (random.Rand(bX, bY + levelSize, bZ) * (1f - dX) + random.Rand(bX + levelSize, bY + levelSize, bZ) * dX) * dY) * (1f - dZ)
97  + ((random.Rand(bX, bY, bZ + levelSize) * (1f - dX) + random.Rand(bX + levelSize, bY, bZ + levelSize) * dX) * (1f - dY)
98  + (random.Rand(bX, bY + levelSize, bZ + levelSize) * (1f - dX) + random.Rand(bX + levelSize, bY + levelSize, bZ + levelSize) * dX) * dY) * dZ
99  ) * _weightTable[level];
100  }
101  return val;
102  }
readonly int Levels
Number of levels incorporated into perlin noise
Definition: Perlin.cs:20
float Rand(int x)
Returns 0-1 float
Definition: Random3D.cs:41
override float pluginbase.Helpers.Computative.Algorithms.Perlin.GetValue ( int  x,
int  y 
)
virtual

Get a 2D value between 0-1

Parameters
xA System.Int32
yA System.Int32
Returns
A System.Int32

Attribute: level

;

Attribute: level

;

Implements pluginbase.Helpers.Computative.ValuePoint3D.

117  {
118  int bX, bY;
119  float dX, dY;
120  float val = 0f;
121  for (int level = 0; level < Levels; ++level)
122  {
123  int levelSize = _sizeTable[level];
124  if (levelSize <= 0){
125  break;
126  }
127 
128  bX = x - MExt.mmod(x, levelSize);
129  bY = y - MExt.mmod(y, levelSize);
130 
131  dX = (x - bX) / (float)levelSize;
132  dY = (y - bY) / (float)levelSize;
133 
134  val += ((random.Rand(bX, bY) * (1f - dX) + random.Rand(bX + levelSize, bY) * dX) * (1f - dY)
135  + (random.Rand(bX, bY + levelSize) * (1f - dX) + random.Rand(bX + levelSize, bY + levelSize) * dX) * dY) * _weightTable[level];
136  }
137  return val;
138  }
readonly int Levels
Number of levels incorporated into perlin noise
Definition: Perlin.cs:20
float Rand(int x)
Returns 0-1 float
Definition: Random3D.cs:41

Member Data Documentation

readonly int pluginbase.Helpers.Computative.Algorithms.Perlin.Frequency

Frequency of the perlin noise

readonly int pluginbase.Helpers.Computative.Algorithms.Perlin.Levels

Number of levels incorporated into perlin noise


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