Closed philogb closed 12 years ago
Perlin noise (of any sort) is not guaranteed to completely cover a particular interval of values, it is only guaranteed to stay within the range [-1, 1], or in some implementations [0, 1]. It is unadvisable to depend on the exact values, because if you want to switch to another implementation with a slightly different range and distribution, like switching to a platform where hardware noise is actually supported some time in the future, your shader might break. Perlin noise is not a good random function. It is a visual pattern primitive that has a somewhat strange and imperfect distribution of values. Depending on what you want to do, you might want to instead use some function of the raw hash values (the output from the integer shuffling of the permutation polynomials), scaled with either 1/289 or 1/288.
The common practice is to just assume that noise has values from -1 to 1 and use 0.5 + noise_0.5 to get values in the range [0,1]. You may want to fiddle with the scaling factor at the end of our noise functions to get your values to cover the desired range more completely, and for 2D noise you can actually test every value by computing a high resolution image with the range [0, 289] for the x and y coordinates and look at a histogram of what you get. If you want to catch all the maxima and minima exactly, render an image with a resolution that is a multiple of 289, like 2890x2890 with coordinates 0 to (1-1/2890)_289 for x and y.
/Stefan G
Stefan,
Thanks for your quick reply. I'll look into some of the functions you mention to use.
Thanks,
On Tue, Jul 31, 2012 at 7:50 AM, Stefan Gustavson reply@reply.github.com wrote:
Perlin noise (of any sort) is not guaranteed to completely cover a particular interval of values, it is only guaranteed to stay within the range [-1, 1], or in some implementations [0, 1]. It is unadvisable to depend on the exact values, because if you want to switch to another implementation with a slightly different range and distribution, like switching to a platform where hardware noise is actually supported some time in the future, your shader might break. Perlin noise is not a good random function. It is a visual pattern primitive that has a somewhat strange and imperfect distribution of values. Depending on what you want to do, you might want to instead use some function of the raw hash values (the output from the integer shuffling of the permutation polynomials), scaled with either 1/289 or 1/288.
The common practice is to just assume that noise has values from -1 to 1 and use 0.5 + noise_0.5 to get values in the range [0,1]. You may want to fiddle with the scaling factor at the end of our noise functions to get your values to cover the desired range more completely, and for 2D noise you can actually test every value by computing a high resolution image with the range [0, 289] for the x and y coordinates and look at a histogram of what you get. If you want to catch all the maxima and minima exactly, render an image with a resolution that is a multiple of 289, like 2890x2890 with coordinates 0 to (1-1/2890)_289 for x and y.
/Stefan G
Reply to this email directly or view it on GitHub: https://github.com/ashima/webgl-noise/issues/8#issuecomment-7400594
Nicolas Garcia Belmonte - http://philogb.github.com/
(snoise(loc) + 1.0) / 2.0
Hi,
I've been reading the wiki for the project and I haven't found a method to do this. I'm trying to get the values for
float snoise(vec2)
to be in a certain interval[0, 1]
. How can I do that? What is the domain forvec2
that I should use as input?Thanks,