Assignment #4 -- Ray Tracing and Shading

Due Date

This assignment is due at 11:59pm on Friday, November 4th. Projects turned in late will lose points as described in the policies handout. This assignment should be done alone or in pairs. You may share ideas with other groups, but you may not share code.


You may develop on Unix, OS X, or Windows. The platform you use will be the one used to grade assignments. Keep in mind that there are slight variations due to OS versions, different libraries, and other factors, so you should verify that your code runs on the instructional machines appropriate for you plat form choice.

As with the last assignment, we will be using Prof. Hilfinger's submit software for submission of this assignment.

You should include a README file that at the minimum contains the following data:

All files needed to compile your code should appear in the submitted directory. It is your responsibility to make sure that they will compile and run properly. You will also need to set the permissions properly.

You will also turn in some images. These should be named "" where nn is a number (e.g. 01, 02, 03...) and xxx is an appropriate extension (e.g. tif, jpg, ppm, etc.) The main input files needed to render those images should be named "input-nn". Finally there should be a "notes-nn" file for each input stating: the command line used to produce image-nn, how long it took to run, what features are demonstrated by the image, any other comments you'd like to add about the image.

Windows: The grader should be able to recompile your program by simply opening the project and rebuilding it from scratch.

Unix and OS X: The grader should be able to recompile your program simply by typing "make".

Do not wait until the last minute to start this assignment. Even a minor bug in a ray tracer typically produces a black image with no other clue about what is wrong... that makes them very hard to debug. If you don't give yourself enough time, you will be most unhappy.

Check the news group regularly for updates on the assignment or other clarification. We will assume that anything posted there is henceforth known to all.


For this assignment, you will write a ray tracer that can at least:
Optional features that you can implement for extra credit are: You will use your program to render 5 or more example scenes that demonstrate the features you have implemented. You will turn in the images rendered by your code, the code, and some documentation (see above). Your images must demonstrate the features you implemented or you cannot get points for those features. You will also receive points for the aesthetics and creativity demonstrated by your images.

Grave Warning: It will be considered cheating to turn in images that were not generated by your code. Cheating on an assignment will earn a zero for the assignment and possibly subject you to disciplinary action.

File Formats

The input file can be in any format you like. You are responsible for coming up with something reasonable and creating inputs for interesting images. An input may consist of multiple files. We recommend starting with the input format used for assignment 3 since you already have a parser for this format. However, you will want/need to make some changes to this format, like including Krefl, the reflection coefficient. Also, it is easier to specify the camera as a center of projection (eye) point and the four corners of the image plane.

Your output needs to be in a standard image format that most image viewers can read. Suggested formats are: JPEG, TIFF, PNG or PPM. Do not use an indexed color format. You can write your own code to write the files or you can use a standard library. PPM is very easy to write, but offers no compression. JPEG, TIFF, and PNG are supported by many standard libraries. (libTIFF, libPNG, ImageMagik, nd many others) You are responsible for figuring out how to use these libraries.

Your images should be at least 640x480 and no more than 1280x1024.


This assignment is purposefully open ended. I am continually impressed by what Berkeley undergrads can do when given a bit of freedom, so here it is. You are encouraged to be creative and enjoy this assignment.

Questions should be posted to the news group