Nature, however, does not work this way.
While there are variations, for example, in the
elevations of a mountain or the curves in a river, there is also a great deal of structure present
as well.
One of the key elements to the variations we see in natural phenomena is that the magnitude
of random variations depends on the scale (or size) at which we perceive these phenomena.
Consider, for example, the textures shown in Fig. 3. By varying the frequency of the noise
we can obtain significantly different textures.
Fig. 3: Perlin noise used to generate a variety of displacement textures.
The tendency to see repeating patterns arising at different scales is called
self similarity
and
it is fundamental to many phenomena in science and nature.
Such structures are studied
in mathematics under the name of
fractals
. Perlin noise can be viewed as a type of random
noise that is self similar at different scales, and hence it is one way of modeling random fractal
objects.
Noise Functions:
Let us begin by considering how to take the output of a pseudorandom number
generator and convert it into a smooth (but random looking) function. To start, let us consider
a sequence of random numbers in the interval [0
,
1] produced by a random number generator
(see Fig. 4(a)). Let
Y
=
h
y
0
, . . . , y
n
i
denote the sequence of random values, and let us plot
them at the uniformly places points
X
=
h
0
, . . . , n
i
.
Next, let us map these points to a continuous function, we could apply linear interpolation
between pairs of points (also called
piecewise linear interpolation
.
As we have seen earlier
this semester, in order to interpolate linearly between two values
y
i
and
y
i
+1
, we define a
parameter
α
that varies between 0 and 1, the interpolated value is
lerp(
y
i
, y
i
+1
, α
) = (1

α
)
y
i
+
αy
i
+1
.
To make this work in a piecewise setting we need to set
α
to the fractional part of the
x
value
that lies between
i
and
i
+1. In particular, if we define
x
mod 1 =
x
b
x
c
to be the fractional
Lecture 12
2
Spring 2018
CMSC 425
Dave Mount & Roger Eastman
1
0
(a)
1
0
(b)
1
0
(c)
Random points
Piecewise linear interpolation
Cosine interpolation
Fig. 4:
(a) Random points, (b) connected by linear interpolation, and (c) connected by cosine
interpolation.
part of
x
, we can define the linear interpolation function to be
f
‘
(
x
) = lerp(
y
i
, y
i
+1
, α
)
,
where
i
=
b
x
c
and
α
=
x
mod 1
.
The result is the function shown in Fig. 4(b).
While linear interpolation is easy to define, it will not be sufficient smooth for our purposes.
There are a number of ways in which to define smoother interpolating functions.
(This is
a topic that is usually covered in computer graphics courses.)
A quickanddirty way to
define such an interpolation is to replace the linear blending functions (1

α
) and
α
in linear
interpolation with smoother functions that have similar properties.
In particular, observe
that
α
varies from 0 to 1, the function 1

α
varies from 1 down to 0 while
α
goes the other
way, and for any value of
α
these two functions sum to 1 (see Fig. 5(a)). Observe that the
functions (cos(
πα
)+1)
/
2 and (1

cos(
πα
))
/
2 behave in exactly this same way (see Fig. 5(b)).