Open In App

Gouraud Shading in Computer Graphics

Last Updated : 03 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Gouraud shading is a method used in computer graphics to simulate the differing effect of light and color across the surface of an object. Intensity- interpolation is used to develop Gouraud shading. By intensity interpolation, the intensity of each and every pixel is calculated. Gouraud shading shades a polygon by linearly interpolating intensity values across the surface. By this, if we know the intensities of two points then we can able to find the intensity of any point in between them. 

By Gouraud shading, we can overcome the discontinue intensity values for each polygon that are matched with the values of adjacent polygons along the common edges.

Each polygon surface is rendered with Gouraud shading by performing the following calculations.

  • The first step is to determine the average normal vector as add a polygon vertex. Determining the average unit normal vertex at each polygon vertex.
Gouraud Shading in Computer Graphics

 

Calculating the average unit normal vector at point p. Point p is attached with four polygons. 

So, the average unit normal vector = N1+N2+N3+N4/|N1+N2+N3+N4|

for n polygons  —-> summation of k Nk / | summation of k Nk |    (where k is initialized from 1 to N)

  • Applying an illumination model at each vertex to calculate vertex intensity.
  • In computer graphics, we use an illumination model to calculate vertex intensity at each vertex.
  • Linearly interpolated the vertex intensities over the surface of the polygon for each scanline the intensity at the intersection with a polygon edge is linearly interpolated.

 

In the above example, the vertex values and intensities of 1,2,3 are given. By linear interpolating, we can find the intensity at point 4 (by points 1 and 2) and at point 5 (by points 3 and 2)

 I4 = (y4-y2/y1-y2)*I1 + (y1-y4/y1-y2)*I2 I5 = (y5-y2/y3-y2)*I3 + (y3-y5/y3-y2)*I2

I1 intensity at vertex 1 
I2 intensity at vertex 2 
I3 intensity at vertex 3 
I4 intensity at vertex 4 
I5 intensity at vertex 5

Now we can able to find the intensity at point p (by points 4 and 5)

Ip = (X5-Xp/X5-X4)*I4 + (Xp-X4/X5-X4)*I5

And now we are taking y-1 as our next scanline.

 

Similar calculations are used to obtain intensities at successive horizontal pixel positions along each scan line. Incremental interpolation of intensity value along a polygon edge for successive scan line:

I = (y-y2/y1-y2)*I1 + (y1-y/y1-y2)*I2   OR I = I + I2- I1/Y1-Y2

When the surfaces are to be rendered in color, the intensities of each color component are calculated at the vertices. Gouraud can be connected with a hidden surface algorithm to fill in the visible polygons along each scan line.

Advantages :

  • Gouraud shading discards the intensity discontinuities associated with the constant shading model.
  • Linear intensity interpolation can cause bright or dark intensity streaks, called match bands, to appear on the surface.
  • The match band effect can decrease by dividing the surface into a higher no of polygon faces or by using other methods such as Phong shading which requires more calculations . 

Disadvantages :

  • Highlights on the surface are sometimes displayed with anomalous shapes.
  • The linear 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 be reduced by breaking the surface into a greater number of smaller polygons.
  • Sharp drop of intensity values on the polygon surface can not be displayed.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads