This document discusses different methods for rendering polygon surfaces with lighting effects, including constant-intensity (flat) shading, Gouraud shading, Phong shading, and fast Phong shading. Constant-intensity shading assigns a single intensity value to each polygon, while Gouraud shading linearly interpolates intensities across polygon surfaces. Phong shading more realistically renders surfaces by interpolating normal vectors and applying lighting models at each point. Fast Phong shading approximates Phong shading calculations to speed up rendering, though with some loss of accuracy.
This document discusses different methods for rendering polygon surfaces with lighting effects, including constant-intensity (flat) shading, Gouraud shading, Phong shading, and fast Phong shading. Constant-intensity shading assigns a single intensity value to each polygon, while Gouraud shading linearly interpolates intensities across polygon surfaces. Phong shading more realistically renders surfaces by interpolating normal vectors and applying lighting models at each point. Fast Phong shading approximates Phong shading calculations to speed up rendering, though with some loss of accuracy.
Original Description:
This document includes some techniques of polygon rendering
This document discusses different methods for rendering polygon surfaces with lighting effects, including constant-intensity (flat) shading, Gouraud shading, Phong shading, and fast Phong shading. Constant-intensity shading assigns a single intensity value to each polygon, while Gouraud shading linearly interpolates intensities across polygon surfaces. Phong shading more realistically renders surfaces by interpolating normal vectors and applying lighting models at each point. Fast Phong shading approximates Phong shading calculations to speed up rendering, though with some loss of accuracy.
This document discusses different methods for rendering polygon surfaces with lighting effects, including constant-intensity (flat) shading, Gouraud shading, Phong shading, and fast Phong shading. Constant-intensity shading assigns a single intensity value to each polygon, while Gouraud shading linearly interpolates intensities across polygon surfaces. Phong shading more realistically renders surfaces by interpolating normal vectors and applying lighting models at each point. Fast Phong shading approximates Phong shading calculations to speed up rendering, though with some loss of accuracy.
Download as TXT, PDF, TXT or read online from Scribd
Download as txt, pdf, or txt
You are on page 1of 3
POLYGON-RENDERING METHODS
In this section, we consider the application of an illumination model to the
rendering of standard graphics objects: those formed with polygon surfaces. The objects are usually polygon-mesh approximations of curved-surface objects, but they may also be polyhedra that are not curved-surface approximations. Scanline algorithms typically apply a lighting model to obtain polygon surface rendering in one of two ways. Each polygon can be rendered with a single intensity, or the intensity can be obtained at each point of the surface using an interpolation scheme. Constant-Intensity Shading 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 bc useful for quickly displaying thegeneral appearance of a curved surface, as in Fig. 14-47. 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. kction 14-5 Polygon-Rendering Memods Figure 14-44 The normal vector at vertex V is calculated as the average of the surface normals for each polygon . sharing that vertex. All light sources illuminating the obpzt are suficiently far from the surface so that N . L and the attenuation function are constant over the surface. *. The viewing position is sufficiently far from the surface so that V R is constant over the surface. Even if all of these conditions are not true, we can still reasonably approximate surface-lighting effects using small polygon facets with flat shading and calculate the intensity for each facet, say, at the center of the polygon. Gouraud Shading This inteneity-interpolation scheme, developed by Gouraud and generally referred to as Gouraud shading, renders a polygon surface by linearly interpolating intensity values across the surface. Iqtensity values for each polygon are matched with the values of adjacent polygons along the common edges, thus eliminating the intensity discontinuities that can occur in flat shading. Each polygon surface is rendered with Gouraud shading by performing the following calculations: Determine the average unit normal vector at each polygon vertex. Apply an illumination model to each vertex to calculate the vertex intensity. Linearly interpolate the vertex intensities over the surface of the polygon. At each polygon vertex, we obtain a normal vector by averaging the surface normals of all polygons sharing that vertex, as illustrated in Fig. 14-44. Thus, for any vertex position V, we obtain the unit vertex normal with the calculation Once we have the. vertex nonnals, we can determine the intensity at the vertices from a lighting model. ~i&e 1445 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. 14-45, 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 bekeen intensities I, and I, using only the vertical displacement of the scan line: Figure 14-45 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. 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. 14-45) is interpolated from the bounding intensities at points 4 and 5 as Incremental caldations are used to obtain successive edge intensity values between scan lines and to obtain successive intensities along a scan line. As shown in Fig. 14-46, if the intensity at edge position (x, y) is interpolated as then we can obtain the intensity abng this edge for the next scan line, y - I, as Incremental interpolation of intensity values along a polygon edge for su-ive r a n lines. 1.1 1 I h 1 -. --- - - - - Fcgrrrr 14-47 A polygon mesh approwmahon of an object (a) is rendered wlth flat shading (b) and with Couraud shading (c). Similar calculations are used to obtain intensities at successive horizontal pixel positions along each scan line. When surfaces are to be rendered in color, the intensity of each color component is calculated at the vertices. Gouraud shading can be combined with a hidden-surface algorithm to fill in the visible polygons along each scan line. An example of an object shaded with the Gouraud method appears in Fig. 14-47. 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. Phong Shading A more accurate method for rendering a polygon surface is to interpolate normal vectors, and then apply the illumination model to each surface point. This method, developed by Phong Bui Tuong, is called Phong shading, or nonnalvector interpolation shading. It displays more realistic highlights on a surface and greatly reduces the Mach-band effect. A polygon surface is rendered using Phong shading by carrying out the following steps: Determine the average unit normal vector at each polygon vertex. Linearly &erpolate the vertex normals over the surface of the polygon. Apply an illumination model along each scan line to calculate projected pixel intensities for the surface points. Interpolation of surface normals along a polygon edge between two vertices is illustrated in Fig. 1448. The normal vector N for the scan-line intersection point along the edge between vertices 1 and 2 can be obtained by vertically interpolating between edge endpoint normals: Chapter 14 N, illumination Models and Surface- Rendering Methods scan line Figutp 14-48 Interpolation of surface normals alonga polygon edge Incremental methods are used to evaluate normals between scan lines and along each individual scan line. At each pixel position along a scan line, the illumination model is applied to determine the surface intensity at that point. Intensity calculations using an approximated n o ~ avle ctor at each point along the scan line produce more accurate results than the direct interpolation of intensities, as in Gouraud shading. The trade-off, however, is that Phong shading requires considerably more calculations. Fast Phong Sh~ding Surface rendering with Phong shading can be speeded up by using approximations in the illumination-model calculations of normal vectors. Fast Phong shading approximates the intensity calculations using a Taylor-series expansion and hiangular surface patches. Since Phong shading interpolates normal vectors from vertex normals, we can express the surface normal N at any point (x, y) over a triangle as where vectors A, B, and C are determined from the three vertex equations: with (g,yk ) denoting a vertex position. Omitting the reflectivity and attenuation parameters, we can write the calculation for light-source diffuse reflection from a surface point (x, y) as -- L . (Ax + By + C) ILI IAX + B~ + CI We can rewrite this expression in the form Section 14-6 Ray-Tracirig Methods where parameters such as a, b, c, and d are used to represent the various dot products. For example, Finally, we can expre5s the denominator in Eq. 14-46 as a Taylor-series expansion and retain terms up to second degree in x and y. This yields where each T, is a function of parameters a, b, c, and so forth. Using forward differences, we can evaluate Eq. 14-48 with only two additions for each pixel position (x, y) once the initial forward-difference parameters have been evaluated. Although fast Phong shading reduces the Phong-shading calculations, it still takes approximately twice as long to render a surface with fast Phong shading as it does with Gouraud shading. Normal Phong shading using forward differences takes about six to seven times longer than Gouraud shading. Fast Phong shading for d i h s e reflection can be extended to include specular reflections. Calculations similar to those for diffuse reflections are used to evaluate specular terms such as (N . H)"s in the basic illumination model. In addition, we can generalize the algorithm to include polygons other than triangles and finite viewing positions.