You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All Perlin noise functions in noise have a scaling factor to map the raw output into [-1.0, 1.0]. The scaling factors are noted as being derived from the maximum value of N-d Perlin noise, which is calculated as sqrt(N) / 2.
This formula matches the calculations done on this Digital Freepen page, and is correct for "classic" Perlin noise. However, noise actually implements "improved" Perlin noise, which differs in 2 important ways:
Improved Perlin noise selects gradient vectors from a small predefined table, making some gradient configurations impossible.
As a result, noise's implementations of 2D, 3D, and 4D Perlin noise can produce values far outside of [-1.0, 1.0]. This can be easily observed once the output clamping is removed:
It should be noted that the script assumes the maximum value can be found at the center of an n-cube, which I believe is true based on the Digital Freepen page. However, I do not really know if this still applies in Improved Perlin noise, as I am unable to follow along with the calculations. Still, if it is to be believed, the true scaling factors should be:
2D: 1.0
3D: 1.0
4D: 16.0 / 23.0
As a side note, it should become increasingly harder to observe maximal values as the number of dimensions increases, as more and more gradient vectors are required to align. This may be a point against setting the scaling factor based on the absolute maximum, as it may result in a reduced range in practice.
The text was updated successfully, but these errors were encountered:
All Perlin noise functions in
noise
have a scaling factor to map the raw output into[-1.0, 1.0]
. The scaling factors are noted as being derived from the maximum value of N-d Perlin noise, which is calculated assqrt(N) / 2
.This formula matches the calculations done on this Digital Freepen page, and is correct for "classic" Perlin noise. However,
noise
actually implements "improved" Perlin noise, which differs in 2 important ways:As a result,
noise
's implementations of 2D, 3D, and 4D Perlin noise can produce values far outside of[-1.0, 1.0]
. This can be easily observed once the output clamping is removed:I wrote a script to greedily maximize the noise value, which I believe finds the true maximum values for each implementation:
It should be noted that the script assumes the maximum value can be found at the center of an n-cube, which I believe is true based on the Digital Freepen page. However, I do not really know if this still applies in Improved Perlin noise, as I am unable to follow along with the calculations. Still, if it is to be believed, the true scaling factors should be:
1.0
1.0
16.0 / 23.0
As a side note, it should become increasingly harder to observe maximal values as the number of dimensions increases, as more and more gradient vectors are required to align. This may be a point against setting the scaling factor based on the absolute maximum, as it may result in a reduced range in practice.
The text was updated successfully, but these errors were encountered: