Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »


In this project, we will implement Gouraud shading for polygons with ambient and point light sources. As a result, our graphics system will become a complete 3D z-buffer rendering system with lighting and shading.


Lighting structures

We created a new Light and Lighting structures to represent lights.

A Light structure represents a light source. Just like in nature, we have different types of lights such as PointLight and AmbientLight. Our light structure also handle properties of light such as direction and position.

A Lighting structure represents a collection of all the lights in a scene. We implement this structure under the form of an array with a maximum capacity of a constant called MAX_LIGHTS. This is practical since even in nature, there are only a definite number of light sources.


The Light_shading function is essential to our project. This function makes use of the illumination model that Prof. Maxwell explained in the lecture notes. The illumination model can calculate the lighting at a given point using the lighting information as well as the drawstate information.

Gouraud shading

Gouraud shading makes use of the illumination model and the concept of interpolation. In a nutshell, Gouraud shading calculates the lighting at the vertices of a polygon. The color is then interpolated across the surface to produce the shading for the whole polygon.

Gouraud shading is fast and simple. However, because the lighting calculation is only approximated on the surface, Gouraud shading can create Mach bands. This leads to aliasing.

Required images

Lighting_shading test

Simple cube



Hieu's image

In this image I created some text using cubes. My scene consists of 3 text modules. There are one Point Light and one Ambient Light in my scene. I make the text rotate to show the shading.

At first I made a mistake while doing the animation but the result image looks pretty neat.

  • No labels