nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
26.31k stars 7.69k forks source link

Fix an issue with out of range value being generated #1478

Closed danemadsen closed 1 year ago

danemadsen commented 1 year ago

Fixes raysan5/raylib#3071

This wan an issue caused by stb_perlin_fbm_noise3 where values outside of the range of -1 to 1 were occasionally generated causing underflow / overflow which resulted in spikes

nothings commented 1 year ago

Occasionally generating a value outside of the range of [-1,1] is the expected behavior. Normalizing as you suggest would radically change the output for all users. Rescaling to a guaranteed range is best done in the caller.