The second shading model, Gouraud shading, computes an intensity for each vertex and then interpolates the computed intensities across the polygons. Gouraud shading performs a bi-linear interpolation of the intensities down and then across scan lines. It thus eliminates the sharp changes at polygon boundaries

The algorithm is as follows:

- Compute a normal N for each vertex of the polygon.
- From N compute an intensity I for each vertex of the polygon.
- From bi-linear interpolation compute an intensity Ii for each pixel.
- Paint pixel to shade corresponding to Ii.

How do we compute N for a vertex? Let N = the average of the normals of the polygons which include the vertex. Note that 4 sided polygons have 4 neighbors and triangles have 6 neighbors. | |

We can find the neighbors for a particular vertex by searching the polygons and including any polygons which include the vertex. Now look at performing the bi-linear intensity interpolation. This is the same as the bi-linear interpolation for the z depth of a pixel (used with the z buffer visible surface algorithm). |

**Advantages of Gouraud shading: **

Gouraud shading gives a much better image than faceted shading (the facets no longer visible). It is not too computationally expensive: one floating point addition (for each color) for each pixel. (the mapping to actual display registers requires a floating point multiplication)

**Disadvantages to Gouraud shading: **

It eliminates creases that you may want to preserve, e.g. in a cube. We can modify data structure to prevent this by storing each physical vertex 3 times, i.e. a different logical vertex for each polygon. here is a data structure for a cube that will keep the edges:

24, 6 number of vertices, number of polygons: right handed
cube

0 -1.00000 -1.00000 -1.00000 0 vertex number, x, y, z simple
vertex number

1 -1.00000 -1.00000 -1.00000 0

2 -1.00000 -1.00000 -1.00000 0 this version is a cube for Gouraud
or

3 -1.00000 -1.00000 1.00000 1 Phong shading that retains the
creases

4 -1.00000 -1.00000 1.00000 1

5 -1.00000 -1.00000 1.00000 1

6 1.00000 -1.00000 1.00000 2

7 1.00000 -1.00000 1.00000 2

8 1.00000 -1.00000 1.00000 2

9 1.00000 -1.00000 -1.00000 3

10 1.00000 -1.00000 -1.00000 3

11 1.00000 -1.00000 -1.00000 3

12 1.00000 1.00000 -1.00000 4

13 1.00000 1.00000 -1.00000 4

14 1.00000 1.00000 -1.00000 4

15 1.00000 1.00000 1.00000 5

16 1.00000 1.00000 1.00000 5

17 1.00000 1.00000 1.00000 5

18 -1.00000 1.00000 1.00000 6

19 -1.00000 1.00000 1.00000 6

20 -1.00000 1.00000 1.00000 6

21 -1.00000 1.00000 -1.00000 7

22 -1.00000 1.00000 -1.00000 7

23 -1.00000 1.00000 -1.00000 7

4 0 9 6 3 number of vertices of polygon, vertices

4 7 10 12 15

4 16 13 21 18

4 19 22 1 4

4 5 8 17 20

4 2 23 14 11

**Gouraud Shading and Specular Highlights**

Gouraud shading does not handle specular highlights very well. Look at the following case of a light source in three different positions relative to a polygon.

If the Phong number is high (corresponding to a small viewing cone and thus a small specular highlight), then the highlight should move across the surface of the polygon as the light is shifted. But since the intensities are only computed at the vertices, the highlight will appear in Case 1, disappear in Case 2, and reappear in Case 3. Also, the highlight will be smeared out in both Cases 1 and 3 since the interpolation of the intensities will cause it to decrease slower than it really should.

A Pixar Shutterbug example image with Gouraud shading and no specular highlights. | |

A Pixar Shutterbug example image with Gouraud shading and specular highlights. |