CMPS 260 Project Procedural Textures - Perlin Noise
Wei Shen
weishen@cse.ucsc.edu
I experimented with multiple approaches of procedural textures and expanded some 2D procedure textures to 3D texture algorithms. My project focuses on Perlin Noise Functions which I use to generate fractal textures such as marble, grain, flame. I try to apply 4D Perlin Noise Functions(Animated 3D Textures) and find that it involves too expensive computation which is not suitable for real time animation. Thus my final program uses 3D algorithms and it's implemented with OpenGL under Visual Studio environment. The GUI is created with FLTK. The whole program is made to be portable for platforms other than Windows.
Conventional random number generators are useful to create unpredictability that can make motion and behavior of objects more natural. However, random number generators' incontinuity makes their output too harsh to appear natural. Perlin Noise Functions, utilize general random number generators, can create patterns with fractal features which exhibit the same pattern of large and small variations. To create a Perlin Noise Function, we need a Noise Function, an Interpolation Function and a Smooth Function.
Noise Function is simply a seeded random number generator. Figure 1 shows one example.

Figure 1. Simple Random Number Generator
(From Hugo's webpage)
I found the following one (From Hugo's webpage) pretty good when apply 3D noise functions (which expands existing 1D noise function):
float noise(int x, int y, int z)
{
int n = x + y * 57 + z * 13;
n = (n<<13) ^ n;
floattemp = (float)(1.0-((n*(n*n*15731+789221)+1376312589)&0x7fffffff)/1073741824.0);
return temp;
}
Interpolation Function can be any of the following approaches: Linear Interpolation, Cosine Interpolation and Cubic Interpolation. Since Linear Interpolation requires less computational power, it's used a lot in 3D and animation applications. 1D Linear Interpolation needs to evaluate noise function at two points, 2D at four points and 3D at eight points.

Figure 2. Interpolated Noise Function
(From Hugo's webpage)
To make the output less random looking, an image smoothing filter should be used before we calculate noise function at a point. In 3D case, one expensive smoothing filter evaluates the noise function at adjacent 27 points to get the smoothed value. Thus to get a single interpolated noise value, we need to evaluate noise function at 8 * 27 = 216 points. We can hardly animate our scene with this expensive approach. There's one much cheaper way to do that: use a much simpler filter that only evaluates the closes 6 points.
Now we can take lots of such smooth functions, with various frequencies and amplitudes, we can add them all together to create a nice Perlin Noise Function.


Figure 3. Creation of Perlin Noise
(From Hugo's webpage)
Expand our Perlin Noise Function to 3D, we can create the following pattern.
Figure 4. Pure 3D Perlin Noise
Sometimes it's better to sum the absolute value of each noise function. We can use this way to get Turbulence Function as figure 5 shows.
Figure 5. Turbulence
A marbly texture can be made by using a Perlin function as an offset to a sine/cosine function.
Figure 6. Marble
Very nice wood textures can be defined. The grain is defined with a low persistence function like this:
g = perlin(x,y,z) * 20
grain = g - int(g)
Figure 7. Wood Grain
Using simple color mapping, we can have a nice color ball.
Figure 8. Simple Color Mapping
Each of the objects shown above consists of 259,200 polygons. Flame in Figure 9 was created with animated Perlin Noise Function. The third dimension is used as time frame. Apply suitable turbulence to a gradient field, put a black disc at the center, then we'll get an animated solar flame. This object consists of 40,000 polygons.
Figure 9. Animated Solar Flame
References
User Guide
My program's GUI has four value sliders to adjust noise parameters, one choice button to choose texture model (pure noise, color map, sin/cos marble, grain pattern and solar flame), two check buttons to control turbulence and animation, and an exit button to quit program.
Program Listing
noise.dsw, noise.dsp -- Visual Studio workspace file and project file
main.cxx-- main program used to create FLTK window
gui.h, gui.cxx --implements FLTK main window class
graphics.h, graphics.cxx -- implements OpenGL window class
q_noise.h, q_noise.cpp -- includes all the functions that implement Perlin Noise Function
q_utils.h, q_utils.cxx -- useful functions such as vector operations, etc.