Lab 9: Shading

Alex Benn and Andrew Frampton

Quick Summary

The first step in creating our shading algorithm was defining a light source. Each light source stores a light type, a color, and, depending on the type, one or more of a direction, position, and spotlight angle. We then coded a number of vector manipulation functions, useful for a number of things. Next, we implemented body illumination and surface illumination for each type of light source. Here's how it works:

Images


Figure 1: Test of Color Interpolation Algorithm


Figure 2: Output of 3D Shading Test Code

Super-Excellent Update! Although the sphere-drawing code demonstrated in Figure 3 below was developed after this lab was due, it demonstrates Gouraud shading quite well.


Figure 3: Gouraud Shading of Sphere

Questions

  1. The Module_sphere() function was added to the Module code in order to demonstrate Gouraud shading. To generate the normals of the polygons, we used the true sphere normal at each point, rather than using the normal to the current polygon, as is used elsewhere. This generates a smooth gradient across the sphere which looks quite nice.

Back to Alex and Andrew's other labs