Silicon Graphics

[Prev] [TOC] [Next]



(-) OpenGL Programming Guide

Appendix F
Calculating Normal Vectors

This appendix describes how to calculate normal vectors for surfaces. You need to define normals to use OpenGL's lighting facility, which is described in Chapter 6, "Lighting.""Normal Vectors" introduces normals and the OpenGL command for specifying them. This appendix goes through the details of calculating them. It has the following major sections:

Since normals are perpendicular to a surface, you can find the normal at a particular point on a surface by first finding the flat plane that just touches the surface at that point. The normal is the vector that's perpendicular to that plane. On a perfect sphere, for example, the normal at a point on the surface is in the same direction as the vector from the center of the sphere to that point. For other types of surfaces, there are other, better means for determining the normals, depending on how the surface is specified.

Recall that smooth curved surfaces are approximated by a large number of small flat polygons. If the vectors perpendicular to these polygons are used as the surface normals in such an approximation, the surface appears faceted, since the normal direction is discontinuous across the polygonal boundaries. In many cases, however, an exact mathematical description exists for the surface, and true surface normals can be calculated at every point. Using the true normals improves the rendering considerably, as shown in Figure F-1 . Even if you don't have a mathematical description, you can do better than the faceted look shown in the figure. The two major sections in this appendix describe how to calculate normal vectors for these two cases:

[IMAGE]

Figure F-1 : Rendering with Polygonal Normals vs. True Normals



(+) Finding Normals for Analytic Surfaces
(+) Finding Normals from Polygonal Data

[Prev] [TOC] [Next]

OpenGL Programming Guide


Maintained by Maintainer: Send e-mail to .htm">name@address.