Graphics Reference
In-Depth Information
Listing 20.1: An implementation of Perlin noise using
a 256
×
256
×
256 cube as a tile.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
( 1, 1, 0 ) , ( 1, 1, 0 ) ,
...
grad[16][3] =
noise(x, y, z)
reduce x, y, z mod 256
i0 = floor(x); j0 = floor(y); k0 = floor(z);
xf=x-i0; yf=y-j0; zf=z-k0;
ax = a(xf) ;
ay = a(yf) ;
az = a(zf); // blending coeffs
fori=0,1;forj=0,1;fork=0,1
h[i][j][k] = hash(i0+i, j0 + j, k0 + k)
// a hash value between 0 and 15
g[i][j][k] = grad[h[i][j][k]]
v[i][j][k] = (x - (i0+i)) * g[i][j][k][0] +
(y - (j0+j)) * g[i][j][k][1] +
(z - (k0+k)) * g[i][j][k][2]
return blend3(v, ax, ay, az)
blend3(vals, ax, ay, az)
// linearly interpolate first in x, then y, then z.
x00 = interp(vals[0][0][0], vals[1][0][0], ax)
x01 = interp(vals[0][0][1], vals[1][0][1], ax)
x10 = interp(vals[0][1][0], vals[1][1][0], ax)
x11 = interp(vals[0][1][1], vals[1][1][1], ax)
xy0 = interp(x00, x10, ay)
xy1 = interp(x01, x11, ay)
xyz = interp(xy0, xy1, az)
return xyz
Figure 20.18: A sphere radially
displacement-mapped with Perlin
noise.
interp(v0, v1, a)
return (1-a) * v0+a * v1
of these patterns is governed by many things: the particular differential equation
representing the change in morphogen A as a function of the concentrations of A
and B , the rate (and direction) of diffusion of the morphogens, and the initial dis-
tribution of concentrations. Turing's idea was that the steady-state concentration
of one of the morphogens might control appearance so that, for example, a zebra's
skin would grow white hair where the concentration of morphogen A was small,
but black hair where it was large.
Turing lacked the computational power to perform simulations, but
Turk [Tur91] and Kass and Witkin [WK91] took his ideas, extended them, and
made it practical to run simulations to predict the steady-state concentrations
resulting from some set of initial conditions, not only on the plane, but also
on more general surfaces. Figure 20.20 shows some examples of the reaction-
diffusion textures that they generated.
20.9 Data-Driven Texture Synthesis
Figure 20.19: A marble vase
with texture based on a complex
combination of noise functions
(Courtesy of Ken Perlin, © 1985
ACM, Inc. Reprinted by permis-
sion).
As a final topic, we'll briefly discuss two methods for generating new texture
from old. The first of these is Ashikhmin's texture synthesis algorithm [Ash01],
which is based on ideas in papers by Efros and Leung [EL99] and Wei and
Levoy [WL00], which in turn follow work of Popat and Picard [PP93]. The input
 
 
 
Search WWH ::




Custom Search