summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2023-05-21 10:28:04 +0200
committerRay <[email protected]>2023-05-21 10:28:04 +0200
commit3a841ac130f90c607c29aa79288b943bbfe569b1 (patch)
tree0557033a8f2535d63907aa87edab93a1fd414885 /src
parentf31df7521a9e59f7a1af3f923630900ad74eb1bc (diff)
downloadraylib-3a841ac130f90c607c29aa79288b943bbfe569b1.tar.gz
raylib-3a841ac130f90c607c29aa79288b943bbfe569b1.zip
REVIEWED: `GenImagePerlinNoise()`, clamp values #3071
Diffstat (limited to 'src')
-rw-r--r--src/rtextures.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/rtextures.c b/src/rtextures.c
index 2d8056d6..87594258 100644
--- a/src/rtextures.c
+++ b/src/rtextures.c
@@ -846,6 +846,10 @@ Image GenImagePerlinNoise(int width, int height, int offsetX, int offsetY, float
// octaves = 6 -- number of "octaves" of noise3() to sum
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]
float np = (p + 1.0f)/2.0f;