## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

213
Noise
10
One of the perpetual challenges of computer graphics has been to create images
that are not only geometrically correct, but are also visually interesting. Texture
mapping of real images is commonly used in this way. Another technique
involves adding procedural “random” eects such as are seen in natural phe-
nomena (clouds, re, smoke), natural materials (marble, wood, granite, sand),
small-scale randomness (random textures in materials), and many other things,
through the use of noise functions. In this chapter we discuss noise functions
The topic of noise is not necessarily associated with shaders, and you
may have encountered it in another computer graphics course. We describe it
separately from the details of shaders because it has interest on its own, and
we will certainly nd that it adds very interesting opportunities for shaders to
use in creating some very aractive images.
214
10. Noise
Fundamental Noise Concepts
A noise function is a real-valued function that takes on values between 0. and 1.
over some domain.
1
A noise function is often generated by determining pseudo-
random numbers (PRNs) at each of a number of xed points in a domain and
processing those values to generate a function across the entire domain. If the
domain is an interval, we have one-dimensional noise; if the domain is a plane
region, we have two-dimensional noise; if the domain is a region in three-dimen-
sional space, we have three-dimensional noise. The values of the noise function
can be used to modify values of such things as the pixel properties in a fragment
shader. In this section we will briey introduce some kinds of noise functions
and their properties, based on one-dimensional noise operations for simplicity.
There are some choices we will need to make as we design a shader that is
to use noise functions. Below we discuss some of those choices. If you are using
glman with your study of shaders, you will nd the noisegraph application as
part of the distribution, and you can use that to experiment with many of the
noise concepts you will nd in this chapter. All the 1D noise function graphs
that you will see as gures in this chapter were developed with noisegraph.
One choice you will need to make is whether you want to use value noise or
gradient noise. The value and gradient noise functions produce results that have
qualitative dierences. Both kinds of noise functions are based on piecewise
interpolating their denitions at a xed set of points in their domain, usually
regularly spaced. Both kinds of noise need values at each point; these are given
by using system-generated pseudo-random numbers. In value noise, the pseudo-
random values at each xed point are used as the noise function values, and the
1. Some noise functions prefer the range –1. to 1. It doesn’t really maer. It just means that you will
transform the noise return values dierently.
The GLSL specification lists a built-in noise function. However, at the time of this
writing, its exact behavior has not yet been universally decided upon. So, while it is in
the spec, you might not be able to use it. This chapter will discuss the fundamentals
of noise for graphics shaders, and will show how glman uses 2D and 3D textures to
get around the absence of a working GLSL noise function. Even if you are not using
glman, you will see how to computationally generate noise, which you can then use by
embedding it in your own texture.

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required