| Assignment 4: Flat, Smooth/Gouraud, Phong Shading | ||||||||||||
| Description: The program was adapted from code provided in CSC830. The purpose of the project was to extend assignment 3 by simulating several openGL calls to provide flat, smooth, and phong shading. The phong lighting model was used for each of the shading models. The phong lighting model has three major terms, ambient, diffuse, and specular. In order to calculate the color of a pixel the terms are calculated for each light and summed up. An additional factor is used to give the object the effect that it is composed of a material. The material factor is multiplied by each term in the phong lighting equation. Flat shading was achieved using the surface normal for each triangle. Given three vertexes a, b, and c the surface normal was calculated as follows: suface_normal = (b-a) X (c-a). The surface normal was then passed to the shading fuction illuminate that used the phong lighting model to compute the triangle color. To implement Gouraud, or smooth shading, the vertex normals were used to calculate a color at each vertex. These colors were then interpolated using the three barycentric coordinates alpha, beta, and gamma in the rasterizer built for assignment 3. Phong shading required interpolating the vertex normals. The interpolation was done in the same manner as the color and triangle rasterization interpolation. The vertex normals were interpolated using the alpha,beta, and gamma barycentric coordinates. The normal was then passed to illuminate and a color was generated per pixel.
| ||||||||||||
Flat, Gouraud/Smooth, and Phong Shading | ||||||||||||
| ||||||||||||