MCPcopy Create free account
hub / github.com/aardappel/treesheets / SimplexNoise

Function SimplexNoise

lobster/src/simplex.cpp:350–364  ·  view source on GitHub ↗

2D Multi-octave Simplex noise. For each octave, a higher frequency/lower amplitude function will be added to the original. The higher the persistence [0-1], the more of each succeeding octave will be added.

Source from the content-addressed store, hash-verified

348// For each octave, a higher frequency/lower amplitude function will be added to the original.
349// The higher the persistence [0-1], the more of each succeeding octave will be added.
350float SimplexNoise(const int octaves, const float persistence, const float scale, const float2 &v) {
351 float total = 0;
352 float frequency = scale;
353 float amplitude = 1;
354 // We have to keep track of the largest possible amplitude,
355 // because each octave adds more, and we need a value in [-1, 1].
356 float maxAmplitude = 0;
357 for( int i=0; i < octaves; i++ ) {
358 total += SimplexRawNoise(v.x * frequency, v.y * frequency) * amplitude;
359 frequency *= 2;
360 maxAmplitude += amplitude;
361 amplitude *= persistence;
362 }
363 return total / maxAmplitude;
364}
365
366// 3D Multi-octave Simplex noise.
367//

Callers 4

AddCubeGenFunction · 0.85
EvalMethod · 0.85
polygonize_mcFunction · 0.85
AddNoiseFunction · 0.85

Calls 1

SimplexRawNoiseFunction · 0.85

Tested by

no test coverage detected