Graphics Reference
In-Depth Information
9.3
Simple Approaches to Shading
The last section described some simple illumination models and how one can use
them to compute the illumination at each point of an object. In this section we show
how this information is used to implement shading in a modeling program. The details
depend on
(1) the visible surface determination algorithm that is used,
(2) the type of objects that are being modeled (linear or curved), and
(3) the amount of work one is willing to do.
Constant Shading. The simplest way to shade is to draw all objects in a constant
color. The visible surface algorithms in Chapter 7 would then suffice to accomplish
that. A more sophisticated model would draw each polygon in the scene with a con-
stant shade determined by its normal and one of the described illumination models.
Constant shading that used facet normals would work fine for objects that
really were linear polyhedra, but if what we were doing was approximating curved
objects by linear polyhedra, then the scene would look very faceted and not smooth.
To achieve more realistic shading, we first consider the case of a world of linear
polyhedra.
Gouraud Shading. Gouraud's scan line algorithm ([Gour71]) computes the illumi-
nation at each vertex of an object using the desired illumination model and then com-
putes the illumination at all other points by interpolation. As an example, consider
Figure 9.6. Assuming that the illumination is known at the vertices A , B , C , and D ,
one computes it at the point X as follows: Let P and Q be the points where the edges
AC and BD intersect the scan line containing X , respectively. Compute the illumina-
tion at P and Q by linearly interpolating the illumination values at A , C , and B , D ,
respectively. The value at X is then the linear interpolation of those two values.
To get the exact illumination values at vertices, normals are needed. These normals
are typically computed by taking the average of adjacent face normals. One needs to
realize though that doing this will have the effect of smoothing out an object. This is
what one wants if our objects are faceted representations of curved objects. On the
other hand, sometimes one wants to show edges, as in the case of a cube, and then
we need to avoid this smoothing operation. When we shade such a face, the normals
of the vertices for that face should be the same as the face normal.
Figure 9.6.
Gouraud shading example.
Search WWH ::




Custom Search