Graphics Reference
In-Depth Information
Creating Normals
First, when you change the geometry that came from your model, how do you
create accurate normals? You may have defined the normals in your original
model, but now the geometry has changed, and you need to compute the new
model's normals. How you can do this depends on the way your geometry is
defined.
In case you have an analytic description of the modified surface or
graphical object, you can compute the surface normal by analytic means. If
you have any two non-collinear vectors in the tangent plane to the surface
at a point, then their cross product (in the
right order) is normal to the surface. So if
you have the surface as an explicit function
surface, z ( x , y ), the two partial derivatives
define tangent vectors dx
= 10 ∂∂
zx
= 01∂∂ that lie in the plane,
and their cross product dx × dy can be com-
puted and normalized to get an analytic
normal. Figure 7.7 shows the function sur-
face of Figure 3.4 with specular lighting
added as discussed in the previous chap-
ter. An exercise at the end of this chapter
encourages you to explore this idea more
generally.
An even more interesting case of this is the general surface, defined
on a rectangular domain with points in 3D space. As an example, consider
Enneper's surface, defined by
and dy
zy
Figure 7.7. A function surface with analytic normals.
xuvuu uv
yuvvuv v
zuvuv
(,)
=− +
=− −+
=−
3
/
3
2
,
2
3
(,)
/
3
,
2
2
(,)
.
It's nice to create exact
normals at vertices of
analytic objects, but it's
even better to do that for
each pixel in the object.
This exact shading is
discussed in Chapter 8.
We will omit the shader code here, but it is straight-
forward to compute the u and v partial derivatives of
each component, build the tangent vectors in the u and
v directions, and use the cross product to compute the
normal to the surface at any point. A full set of applica-
tion and shader code is available for this on the topic's
website. Figure 7.8 shows the surface.
Search WWH ::




Custom Search