CMSC 435/634: Introduction to Computer Graphics

Assignment 5
Lighting
Due November 17, 2006

Last update:
Wed Nov 1 15:30 EST 2006

The Assignment

For this assignment, you will add lighting computations to your ray tracer from assignment 4. Working ray tracing code is available on request. Your new lighting computations will consists of two parts, the local surface shading, including diffuse and Phong-specular components, and limited global effects through secondary rays for shadows, reflection and refraction. You will need to use the 'l' light position and color lines from the NFF file, as well as the remaining parameters from the 'f' object material lines. For the basic assignment, you need only shade polygons using the polygon normal. Shading of other primitives or polygons with per--vertex normals is extra credit.

For each intersection, you will shoot shadow rays toward each light to determine if the light is visible from the intersection point. Visible lights should contribute:

localColor = lightColor * (Kd*surfaceColor*diffuse + Ks*specular)

In addition, if Ks>0, you should spawn a reflection ray, and if T>0, you should spawn a refraction ray, resulting in a total color:

totalColor = localColor + Ks*reflection + T*refraction

This is a recursive process, since the color of each reflection and refraction ray is the totalColor of whatever they hit. To avoid infininite recursion, limit the ray tree depth (i.e. number of bounces) to 5. You may skip the reflection or refraction ray if the contribution to the final color would be less than 1/255, but that optimization is not necessary.

Extra credit

There are a variety of extra credit options to add normals and shading computations for different primitive types: shading of spheres (5 pts), shading of cones (15 pts), and either interpolated normals for triangular 'pp' polygon primitives (5 pts) or interpolated normals for arbitrary 'pp' primitives (10 pts). You can also modulate the reflected and refracted ray contribution by the Fresnel reflectance equations for unpolarized light (5 pts).

634 only

Add any physically plausible BRDF as an alternative to the Phong model. You should add a new surface specification line using any unused letter code to specify the parameters needed for your model. You should be able to have objects with both Phong and BRDF models in the same scene. Say you chose 'x' — each new 'x' or 'f' line should override any previous 'x' or 'f'. In other words, primitives given after an 'f' line should use the Phong model, and primitives after an 'x' line should use your chosen BRDF. Include at least one sample NFF file demonstrating your extension.

What to turn in

Turn in this assignment electronically by checking your source code into your Assn5 CVS directory by 11:59 PM on the day of the deadline. As always, double check that you have submitted everything we need to build and run your submission. Be sure to include a Makefile that will build your project when we run 'make', and a readme.txt file telling us about your assignment. Do not forget to tell us what (if any) help did you receive from books, web sites or people other than the instructor and TA, what (if any) extra credit features you added, and (if 634) about your BRDF, NFF extension, and test file.