Shading (Gouraud and Phong
Shading (Gouraud and Phong
Shading (Gouraud and Phong
A fast and simple method for rendering an object with polygon surfaces is constant- intensity shading,
also caned flat shading. In this method, a single intensity is calculated for each polygon. All points
over the surface of the polygon are then displayed with the same intensity value. Constant shading can
be useful for quickly displaying the general appearance of a curved surface.
In general, flat shading of polygon facets provides an accurate rendering for an object if all of the
following assumptions are valid
- The object is a polyhedron and is not an approximation of an object with a curved surface.
- All light sources illuminating the object t are sufficiently far from the surface so that N . L and the
attenuation function are constant over the surface.
Gouraud Shading
Each polygon surface is rendered with Gouraud shading by performing the following calculations:
At each polygon vertex, we obtain a normal vector by averaging the surface normals of all polygons
sharing that vertex, as illustrated in Fig.
The normal vector at vertex V is calculated as the average of the surface normals for each polygon sharing that vertex.
Thus, for any vertex position V, we obtain the unit vertex normal with the calculation
Once we have the vertex normals , we can determine the intensity at the vertices from a lighting
model.
For Gouraud shading, the intensity at point 4 is linearly interpolated from the intensities at vertices 1 and 2. The intensity at
point 5 is linearly interpolated from intensities at vertices 2 and 3. An interior point p is then assigned an intensity value that
is linearly interpolated from intensities at positions 4 and 5.
Figure demonstrates the next step: interpolating intensities along the polygon edges. For each scan
line, the intensity at the intersection of the scan line with a polygon edge is linearly interpolated from
the intensities at the edge endpoints. For the example in Fig the polygon edge with endpoint vertices
at positions 1 and 2 is intersected by the scan line at point 4. A fast method for obtaining the intensity
at point 4 is to interpolate between intensities I1, and I2, using only the vertical displacement of the
scan line:
Similarly, intensity at the right intersection of this scan line (point 5) is interpolated from intensity
values at vertices 2 and 3. Once these bounding intensities are established for a scan line, an interior
point (such as point p in fig) is interpolated from the bounding intensities at points 4 and 5 as
Incremental calculations are used to obtain successive edge intensity values between scan lines and to
obtain successive intensities along a scan line. As shown in Fig. if the intensity at edge position (x, y)
is interpolated as
Incremental interpolation of intensity values along a polygon edge for successive scan lines.
then we can obtain the intensity along this edge for the next scan line, y - I, as
Similar calculations are used to obtain intensities at successive horizontal pixel positions along each
scan line.
Gouraud shading removes the intensity discontinuities associated with the constant-shading model,
but it has some other deficiencies. Highlights on the surface are sometimes displayed with anomalous
shapes, and the linear intensity interpolation can cause bright or dark intensity streaks, called Mach
bands, to appear on the surface. These effects can be reduced by dividing the surface into a greater
number of polygon faces or by using other methods, such as Phong shading, that require more
calculations.