Skip to end of metadata
Go to start of metadata

Hieu Phan & Dan Nelson
Please find our code in nelson-phan/


Merry Christmas! To celebrate the end of the 1st half of graphics, we are going to implement Phong Shading and Texture Mapping. Hieu was especially excited to implement Phong Shading since Bui Tuong Phong is from Vietnam. In Dan's words, Hieu has to do Phong shading for his legacy (smile) .


Phong Shading

Phong shading is a more rigorous (and costly) version of Gouraud shading. In Gouraud shading, lighting is calculated at each vertex of the polygon and the color is interpolated across the surface. This can leads to aliasing. Phong shading solves this problem by calculating the lighting at EVERY pixel location in the polygon.

To implement Phong Shading, we interpolate the world coordinates of the vertices and the world coordinates of the normal vectors across the surface. We then use the illumination model (Lighting_shading) to do shading at each pixel.

Texture Mapping

The concept of texture mapping is quite simple: Mapping each pixel location in the polygon to a corresponding "patch" in the texture image. In a more mathematical sense, we have to take the parametric representation of the surface and transform it to the texture coordinates.

In this project, we implemented Z-Buffer texture mapping. We calculate the texture coordinates at each vertex of the polygon and interpolate the texture coordinates across the surface.

The texture coordinates define an area on the image that should be mapped to a pixel in the polygon. We calculate the color information by averaging the color values inside the bounding box of the area.



The image on the left is shaded using Phong Shading. The image on the right is from project 8 - Gouraud Shading.
It is hard to notice the difference. A better example would be on a bigger curved surface.


Test image

Hieu's image

I modified Module_cube to include the textures into the module and texture coordinates into the faces of the cube.

I like how the black background of the image blends completely into the background. And I accidentally left the source image as a part of the animation, so if you keep looking, the creepy face will pop up IN YOUR FACE..


Another very detail-oriented project! There were another few tinnyyyy slips that we made, which costed us hours and hours of debugging.