written 6.7 years ago by | • modified 6.7 years ago |
Gouraud Shading: -
In this method, the intensity interpolation technique developed by Gouraud is used, hence the name. The polygon surface is displayed by linearly interpolating intensity values across the surface. Here, intensity values for each polygon are matched with the values of adjacent polygons along the common edges. This eliminates the intensity discontinuities that can occur in flat shading.
By performing following calculations we can display polygon surface with Gouraud shading.
1. Determine the average unit normal vector at each polygon vertex.
2. Apply an illumination model to each polygon vertex to determine the vertex intensity.
3. Linearly interpolate the vertex intensities over the surface of the polygon.
We can obtain a normal vector at each polygon vertex by averaging the surface normal in all polygons sharing that vertex. This is illustrated in figure (f) below.
As shown in the figure (f). there are three surface normal’s N1, N2, and N3 of polygon sharing vertex V .Therefore, normal vector at vertex V is given as
In general, for any vertex position V, we can obtain the unit vertex normal by equation
where n is the number of surface normal’s of polygons sharing that vertex.
The next step in Gouraud shading is to find vertex intensities. Once we have the vertex normal’s, their vertex intensities can be determined by applying illumination model to each polygon vertex. Finally, each polygon is shaded by linear interpolating of vertex intensities along each edge and then between edges along each scan tine. This is illustrated in figure (g).
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 example, in figure (g),the polygon edge with endpoint vertices 1 and 2 is intersected by the scan line at point ‘a’. The intensity at point 'a’ can be interpolated from intensities I1 and I2 as
Similarly, we can interpolate the intensity value for right intersection (point b) from intensity values I2 and I3 as
Once the intensities of intersection points a and b are calculated for a scan line, the intensity of an interior point (such as P in Fig.(g)) can be determined as
During the scan conversion process, usually incremental calculations are used to obtain the successive edge intensity values between the scan lines and to obtain successive intensity along a scan line, this eliminates the repeatative calculations.
If the intensity at edge position (x, y) is interpolated as
Then we can obtain the intensity along this edge for next scan line at y -1 position as (see Fig. (h))
Similarly, we can obtain intensities at successive horizontal pixel positions along each scan line (see Fig. (i)) as
Advantages:-
It removes the intensity discontinuities exists in constant shading model.
It can be combined with a hidden surface algorithm to fill in the visible polygons along each scan line.
Disadvantages:-
Highlights on the surface that are sometimes displayed with anomalous shapes.
The 1inear intensity interpolation can result bright or dark intensity streaks to appear on the surface. These bright or dark intensity streaks are called Mach bands. The mach band effect can he reduced by breaking the surface into a greater number of smaller polygons.
Sharp drop of intensity values on the polygon surface cannot be displayed.
Phong Shading :-
Phong shading, also known as normal-vector interpolation shading, interpolates the surface normal vector N, instead of the intensity.
By performing following steps we can display polygon surface using Phong shading.
1. Determine the average unit normal vector at each polygon vertex.
2. Linearly interpolate the vertex normal’s over the surface of the polygon.
3. Apply an illumination model along each scan line to determine projected pixel intensities for the surface points.
The first steps in the phong shading is same as first step in the Gouraud shading. In the second step the vertex normal’s are linearly interpolated over the surface of the polygon. This is illustrated in figure (j). As shown in the figure( j), 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 normal’s:
Advantages:-
I. It displays more realistic highlights on a surface.
lt greatly reduces the Mach-band effect.
It gives more accurate results.
Disadvantage:-
- It requires more calculations and greatly increases the cost of shading steeply.