3.4 Noise

The available noise functions are given in Tables 3.6, 3.7, and 3.8. Noise functions are useful in many situations, for instance, to give a surface an organic appearance. Each of these functions can compute N channels of noise on an M-dimensional input space.

The hash function procedurally computes a floating-point number which is a deterministic function of its input. Inputs with different integer parts will result in outputs that appear to be unrelated to one another. The texhash function is similar, but uses a lookup table stored in a texture. It may be faster to use texhash on some targets, although this limits the resolution of the hash function. Neither function is guaranteed (at present) to be the same on all platforms. Both hash functions depend only on the integer part of their inputs.

The cellnoise function is an interface to either hash or texhash, depending on compilation target and a global option. For instance, on GPU vertex shader targets that don’t support texture maps, cellnoise must use the procedural function hash. The rest of the noise functions are built on top of cellnoise.

The noise function implements the original Perlin noise function [?], and the perlin function implements the “new and improved” (but more expensive) Perlin noise function [?]. A cheaper noise function that can replace Perlin noise in some circumstances is provided by linnoise, which just linearly interpolates cellnoise.

These noise functions can compute and sum several octaves of noise, with a different weight for each octave. For instance, if noise(a) is the basic Perlin noise, we support a generalization as follows:

                K sum -1
noise(a, b)  =      binoise(2ia).
                 i=0

The basic noise functions return values in the range [0,1]. The versions prefixed with “s” return values in the range [-1,1].

The turbulence function computes a weighted sum of octaves of absolute values of snoise:

                     K sum -1 |           |
turbulence(a, b)  =      bi||snoise(2ia)||.
                      i=0

The worley function approximates the Worley basis functions [?], which are based on the Kth distance to randomly placed points (centers). Our implementation currently uses a jittered grid of centers rather than a true random distribution. The value returned by the worley function is a weighted combination of the distances to the Kth closest centers. The maximum size of K is 3M.

The weight vectors are optional and if not given, a weight of 1 is assumed and one octave (or the closest distance in the case of worley) is computed.

Some of these noise functions may be quite expensive, especially at higher input dimensionalities. The worley and perlin functions, as well as related functions such as turbulence, may compile to a large number of instructions on backends which do not have a hash function or noise built in (which is all of them at the time this was written). In fact, the implementation of worley will grow exponentially with dimension.





Operation  r <-- a,b,c,...Description






cellnoise<N>  N <-- M Generic hash based on only the integer part of a; /  E   may be implemented using either hash or texhash, depending on a program definition-time constant or the target.



scellnoise<N> N <-- M Signed version of cellnoise






hash<N>  N <-- M Procedural hash function.



texhash<N>  N <-- M Texture-based hash function.



 


Table 3.6: Hash functions.





Operation  r <-- a,b,c,...Description






/ E  linnoise<N> N <-- M,[K] Compute b-weighted sum of K octaves of bilinearly interpolated cellnoise.



/ E  noise<N>  N <-- M,[K] Compute b-weighted sum of K octaves of Perlin’s original noise function, implemented using cubic interpolation.



perlin<N>  N <-- M,[K] Compute b-weighted sum of K octaves of Perlin’s improved noise function, implemented using a fifth-degree polynomial.



turbulence<N>  N <-- M,[K] Compute b-weighted sum of K octaves of the absolute value of snoise.



worley<N>  N <-- M,[K] Worley noise function; Compute b-weighted sum of distances to the K nearest centers (points on a jittered grid) to a.



 


Table 3.7: Noise functions.





Operation  r <-- a,b,c,...Description






/ E  slinnoise<N> N <-- M,[K] Signed version of linnoise.



/ E  snoise<N>  N <-- M,[K] Signed version of noise.



sperlin<N>  N <-- M,[K] Signed version of perlin.



sturbulence<N>  N <-- M,[K] Signed version of turbulence.



 


Table 3.8: Signed noise functions.


Note: This manual is available as a bound book from AK Peters, including better formatting, in-depth examples, and about 200 pages not available on-line.