Skip to end of metadata
Go to start of metadata

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

Purpose

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.

Algorithms

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.

Light_shading

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

XWings

Starfuries

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.

Conclusions

This project helped us learn a lot about how to model lighting as well as the illumination model. It is a very detailed-oriented project as well. There were a few tiny mistakes that took us days to debug. Motto of the project: Bad things happen if you don't pay attention.

Labels