Viewpoint
By: Gergely Vass
Issue: Volume: 33 Issue: 1 (Jan. 2010)

Viewpoint

Procedural Randomness


The most basic pitfall of creating shaders or materials for 3D renderings is the use of too clean, too perfect textures. In reality, every singe object, surface, or material is worn, dirty, or naturally imperfect to some extent. By photographing or scanning real textures, we get these patterns for free, which helps to “sell” the final 3D image. While procedural textures, generated completely by mathematical algorithms, have many advantages over acquired image textures, reproducing the natural randomness may be especially challenging. As we will see, there is much more to natural-looking noise textures than simply perturbing the RGB values with random numbers.

Randomness itself is a tricky thing in the realm of computer science, where everything is based on a series of deterministic commands. There is no way to let a typical processor flip a coin or roll dice; thus, it is not possible to produce “true” random numbers. Instead, computational algorithms are used to generate long sequences of apparently random results, called pseudo-random numbers. The heart of such algorithms is the iteration step: given an input number, we compute another, apparently independent one. By repeating this step, we can produce extremely long pseudo-random sequences that are prefect for many applications: computer games, music playlists, dynamic simulations, or even computer animation. For applications where true randomness is critical—lottery or cryptography, for instance­—higher quality random numbers are required. Before the 1950s, large tables of random numbers were published for use by mathematicians and scientists, but now it is possible to buy hardware-based random number generators (RNGs) or to rely on services, such as www.random.org, where the numbers are produced based on the physical measurement of atmospheric noise.


A former Maya TD and instructor, Gergely Vass eventually moved to the Image Science Team of Autodesk Media and Entertainment. Currently he is developing advanced postproduction tools for Colorfront in Hungary, one of Europe’s leading DI and post facilities. Vass can be reached at gergely@colorfront.com.

To emulate natural random processes, we can generate a series of pseudo-random numbers and, thus, form a digital random signal. However, not all noise signals are the same. Audio noise—a one-dimensional signal—may refer to a high-frequency “hiss” sound or a lower-frequency “humming” noise, as well. Based on their spectral statistical characteristics, one-dimensional noise signals are often classified using the “color” terminology: white noise, pink noise, brown noise, purple noise, and so forth. These typical (and sometimes only theoretical) random signals have an important role and are commonly used in acoustics, electrical engineering, and physics. White noise—for example, a signal that has the same power over all the frequencies—is essential in calibrating amplification systems (and is likely to drive you crazy if you happen to arrive too early to a summer music festival). By feeding the sound system with white noise, the audio engineer is able to determine which frequencies need to be equalized by measuring the power distribution of the output sound.

In computer graphics, one-dimensional random signals are primarily used to perturb animation channels. An “inactive” human character standing still in a computer game will never appear realistic unless some low-frequency random motion is applied to its muscles. The constant motion due to our body’s physiological actions, including pumping blood or breathing, as well as the constant oscillation of muscle tissue, is typically very slow, thus we need a random signal without any high-frequency components. A simple series of random numbers is of no use for such applications: We need algorithms generating random signals of controllable frequency range. The same concept is true for noise textures—the secret ingredients to make realistic particle or crowd simulations, shaders, or lights. These, two- or three-dimensional noise signals are not simply “soups” of random pixels, but an apparently random series of dark/bright spots. By constraining the sizes of the variations into a well-defined range, we get a chance to match any natural ran­dom pattern and avoid aliasing artifacts. (We certainly do not want random variations smaller than a pixel in the final image.)


Planetside Software’s Terragen 2 uses procedural noise textures to create virtual landscapes. Image by Saurav Subedi.

The visual properties—such as contrast and density—of noise textures need to be precisely controllable so we can use them as a building block to create various natural-looking shading networks. As all natural random patterns, dirt, sand, grass, clouds, or grains have some distinct structure to them, we need to be able to produce the matching procedural texture of similar-sized random features. The first solution to this problem was proposed by Ken Perlin as early as 1983, just about the time when the movie Tron was released. Later, in 1997, Perlin received a Technical Achievement Award from the Academy of Motion Picture Arts and Sciences for his contributions to procedural noise textures. Variations of so-called Perlin Noise are still commonly used; they are easy to control for artists and are able to produce realistic aesthetics. (For further information on Perlin Noise, visit www.noisemachine.com/talk1.)

When computing pseudo-random signals, we always start with an initial seed number. This single value—and the production steps, of course—completely determine the whole sequence. Is this a problem for us? Not at all! One benefit is the minimal memory requirement to store such random textures, regardless of resolution. The other critical aspect is repeatability. Imagine that we create a complex particle simulation with a turbulent dynamic field driven by a 3D noise texture. If the signal were truly random, we would have to save the complete simulation to disk, as the final sequence would look different each time we ran it. However, by initializing the noise generation with the same seed number, it is guaranteed that the virtual leaves blown by our turbulent wind will move the same each time we run the sim. But what if the client picks up on a single particle moving in a strange way? We can simply enter a different seed number and have a brand-new simulation with a turbulence of similar “statistical” properties.


Perlin Noise textures of one, two, and four octaves are used to displace the surface of the spheres.

While photographed dirt textures are images that need to be mapped into the surface of 3D models, the basis of the Perlin (and almost all other) noise is a pseudo-random signal that fills the 3D space. Using 3D, or volumetric procedural textures, we can completely avoid texture mapping as each point of the surface is mapped to a texture coordinate, without introducing any mapping artifacts. It is like inserting the object into a 3D cloud of noise and slicing out the final texture with the surfaces: There will not be any seams or areas of different resolution. Another key property of Perlin Noise is that the sizes of the random variations are roughly the same. While a single layer of the texture may appear a bit too uniform, combining several layers, or octaves, of various characteristic sizes results in a very rich, realistic look. In doing this, we maintain complete control over the frequencies in the deterministic random signal.