The texture map is defined in three dimensions, T(x,y,z), and will be mapped onto a three dimensional object. For each point in three dimensional space we must find the corresponding point in the 3D texture map space and color the 3D point with the value from the texture map. 3D texture maps are generally not stored, because they would be too large, and so are procedurally defined and computed when needed. Thus, this method is frequently called procedural texturing. Note that for ray traced images, the intersection point is the 3D world point to use in the procedural texture.
For example; Wood grain can be simulated by a set of concentric cylinders with alternating dark and white stripes and with the reference axis tilted with respect to the object axis. So we get the texture space coordinate (u, v, w) = Tilt (xw, yw, zw) where Tilt is a linear transformation, e.g., set of rotations about x, y, or z.
For a concentric cylinder: radius = sqrt (sqr (u) + sqr (v)), but we get a more realistic pattern if we apply a sinusoidal perturbation, so use:
radius = radius + n * sin (m * angle).
try n = 2, m = 20 angle = arctan (u, w) and w /= 0 >= p / 2 if w = 0
Note: map angle to region 0 to 2p.
Then can also apply a twist along axis of cylinder in term v / k.
Then we have:
radius = sqrt (sqr (u) + sqr (w)) + 2*sin (20*angle + v/150)
grain = round (radius) mod 60
if grain < 40 then r, g, b -> light_values
else r, g, b -> dark_values
|We can vary all "magic numbers" and have more than two grains levels if we want. Here is an image created using this algorithm.|
A different approach is to use turbulence. e.g., a general 3-D noise function perturbs a field rather than use a content dependent function as for wood grain.
As an example, marble can be emulated by a set of alternating black, grey, white, grey slabs which are perturbed to emulate turbulent flow. We use dd (below) to determine which stripe (different width): 0-3 (white), 4-8 (grey), 9-11 (black), 12-16 (grey).
One model is
width = 0.02; d = (u + 15000)*width + 7 * noise (u/100, v/200, w/200); dd = trunc (d) mod 17 ; if dd < 4 then /* white*/ i = 0.7 + 0.2 * noise (u/70, v/50, w/50); else if (dd < 9 or dd >= 12) then /* grey */ d = abs (d - trunc (d/17)*17 - 10.5)*0.1538962; i = 0.4 + 0.3 * d + 0.2 * noise (u/100, v/100, w/100); else /* black */ i = 0.2 + 0.2 * noise (u/100, v/100, w/100);
r = 0.9 * i ; g = 0.8 * i ; b = 0.6 * i ;
|Here is an example image using this algorithm to simulate marble.|
The input is 3-D real vector and the output is a pseudo-random number. It must have the following properties :
Here is a sample noise function.
Main Texture Mapping Page
HyperGraph Table of Contents.
HyperGraph Home page.