Graphics Reference
In-Depth Information
n
5
n
1
r t 1 1
g t 2
n
g
r
Inline Exercise 20.2: Write a formula to convert values from 0 to 255 into
values from
1to1.
t 2
We can now adjust the normal vector n , as shown in Figure 20.4, by computing
t 1
n = S ( n + r t 1 + g t 2 ) .
(20.3)
Figure 20.4: The vector n will be
normalized to produce the new
normal n ; the values r and g (for
“red” and “green”) vary across
the surface, and are looked up in
a texture map.
At the extreme (when r = g = 1) this tilts the normal vector by about 54 .Ifa
larger amount of tilt is needed, one can redefine r and g to range from
2to2,or
even more.
One advantage to this scheme, originally proposed by Blinn [BN76], is that
n + r t 1 + g t 2 can never be zero, because its dot product with n is one. This means
that it can always be normalized.
By the way, the particular form we've described for converting image-pixel
values into values between
1.0 and 1.0 is part of the OpenGL standard and is
called the signed normalized fixed-point 8-bit representation (see Chapter 14).
There are other standard representations as well, using more bits per pixel,
unsigned rather than signed values, etc. There's nothing sacred about any of these.
They've proven to be convenient over the years, so they become standardized.
A more direct approach is to store in the texture image three floating-point
numbers (i.e., we treat the bits in the red channel as a float, and do the same for
green and blue), and use this triple of numbers as the coordinates of the (unnor-
malized) normal vector, from which we can compute n ; this is one of the most
common approaches today.
It's possible to specify a set of normal vectors that are not actually con-
sistent with each other, that is, they do not form the normal vector field for any
surface (see Exercise 20.2). When rendered, these can look peculiar. So a third
approach to bump mapping is to have the texture contain a height for each tex-
ture coordinate ( u , v ) , indicating that we are to imagine that the surface is dis-
placed from its current position by that amount along the original normal vector.
The resultant surface (which is never actually created!) has tangent vectors in the
u - and v -directions (i.e., the direction of greatest increase of u , and correspond-
ingly of v ), whose cross product we compute and use as the “normal” vector dur-
ing shading computations. This clearly requires substantially more computation,
but far less bandwidth, since we need only one value per location rather than two
or three.
20.2.3 Contour Drawing
This example differs from the previous ones, because each surface point will have
only one texture coordinate. A point P of a smooth surface is on a contour if the
ray from P to the eye E , r = E
P , is perpendicular to the surface normal n .
Thus, to render a surface by drawing its contours, all we must do is compute this
dot product, and when it's near zero, make a black mark on the image, or leave
the image white otherwise. To do so we make a one-dimensional texture map like
the one shown in Figure 20.5. And as a texture coordinate, we compute
5
5
5
d = r
·
n
(20.4)
u
0
u
0.5
u
1
u = d + 1
2
Figure 20.5: A contour-drawing
1D texture.
.
(20.5)
 
 
 
Search WWH ::




Custom Search