Implementation of Perlin Noise on GPU
An Independent study
(Fall 2007)
by

LEENA KORA

Abstract:  The aim of my independent study was to implement Perlin noise on GPU using Cg and compare old method of producing Perlin Noise with the new improved method.

Explaination:
Noise is an important building block for adding natural looking variety to procedural textures. In the real world, nothing is perfectly uniform, and noise provides a controlled way of adding this randomness to our shaders. Perlin noise is one way of  generating an effecient random noise.

Perlin's noise has following characteristics.
• It produces a repeatable pseudorandom value for each input value.
• It has known range.
• It doesn't show obvious repeating patterns.
• Its spatial frequency is invariant under translation.
• It has band-limited spatial frequency.
Old Perlin Noise algorithm is as follows

1. Given an input point
2. For each of its neighboring grid points:
Pick a "pseudo-random" direction vector
Compute linear function (dot product)
3. Linearly combine with a weighted sum, using a cubic ease curve in each dimension, such as 3t2-2t3,
as the interpolant. so the fade function in the below implementation returns " t*t*(3.0-2.0*t)"
4)To compute the pseudo-random gradient, we can first precompute a table of permutations P[n], and a

New Perlin Noise algorithm is as follows

This algorithm has two main stages.
1) The first stage generates a repeatable pseudorandom value for every integer (x,y,z) position in 3D space. Improved Perlin noise algorithm uses a hash function. The hash function is based on a permutation table that contains     the integers from 0 to 255 in random order.First table is indexed based on the x-coordinate of the position. Then the y coordinate is added to the value at this position in the table, and the result is used to look up in the table         again. After this process is repeated for the z cordinate, the result is a pseudorandom integer for every possible (x, y, z) position.
2) In the second stage, this pseudorandom integer is used to index into a table of 3D gradient vectors. In the improved algorithm, only eight different gradients are used. A scalar value is calculated by taking the dot product         between the gradient and the functional position within the noise space. The final value is obtained by interpolating between the noise values for each of the neighboring eight points in space.
So the fade function in the below implementation returns "t*t*t*(t*(t*6.0-15.0)+10.0)".

Tools used for implementation: Cg for implementing shaders, opengl and glut for GUI and window management respectively.

Perlin Noise

Below snap shots show noise generated using both old and new(improved) Perlin noise method.

 Old Perlin Noise Improved Perlin Noise

Marble Texture

Below snap shot shows marble texture generated using Improved Perlin noise algorithm.

 Marble Texture using Improved Perlin Noise

Wood Texture

Below snap shot shows wood texture using improved Perlin noise algorithm.

 Wood texture using Improved Perlin Noise

Cloud Texture

Below snap shot shows cloud texture using improved Perlin noise algorithm.

 Cloud texture using Improved Perlin Noise

Fur Texture

Below snap shot shows fur texture using improved Perlin noise algorithm.

 Fur texture using Improved Perlin Noise

Following are some of the mixed color textures generated using Improved Perlin Noise.

References

1)
Chapter 26 titled as "Implementing Improved Perlin Noise" of the GPU Gems 2 Book by Tim Sweeney , Epic Games

2)  http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

3)  http://www.cs.utah.edu/classes/cs6620/13-6up.pdf