REVIEWED: GenImagePerlinNoise(), clamp values #3071
This commit is contained in:
parent
f31df7521a
commit
3a841ac130
|
|
@ -846,6 +846,10 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float
|
||||||
// octaves = 6 -- number of "octaves" of noise3() to sum
|
// octaves = 6 -- number of "octaves" of noise3() to sum
|
||||||
float p = stb_perlin_fbm_noise3(nx, ny, 1.0f, 2.0f, 0.5f, 6);
|
float p = stb_perlin_fbm_noise3(nx, ny, 1.0f, 2.0f, 0.5f, 6);
|
||||||
|
|
||||||
|
// Clamp between -1.0f and 1.0f
|
||||||
|
if (p < -1.0f) p = -1.0f;
|
||||||
|
if (p > 1.0f) p = 1.0f;
|
||||||
|
|
||||||
// We need to normalize the data from [-1..1] to [0..1]
|
// We need to normalize the data from [-1..1] to [0..1]
|
||||||
float np = (p + 1.0f)/2.0f;
|
float np = (p + 1.0f)/2.0f;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user