
478 11. Algorithms for procedural textures
//Given the p o int of interest as a (u, v, w) coordinate.
//Displace the s a mp lin g point (u, v, w) by obtaining a turbulence vector ∆p
vTurbulence(∆p, u, v, w, )
u
′
= u + t∆p
u
v
′
= v + t∆p
v
w
′
= w + t∆p
w
//Sample the nois e function at (u
′
, v
′
, w
′
) and blend colors:
n = fNoise(u
′
, v
′
, w
′
)
i f (n < 0.5) //return the background color
e ls e i f (n < 0.6) {
//Blend to whit e from background: B
f = 10(n − 0.5)
r = r + f (1 − B
r
)
g = g + f (1 − B
g
)
b = b + f (1 − B
b
)
}
e ls e {
//Blend to gray:
f = 1 − 5(n − 0.6)
r = fr
g = f g
b = f b
}
Listing 11.8: Procedure to create the texture illus tr a t ed in figure 11.18. The parameter ...