cos426.jpg (39279 bytes)

Computer Graphics, Spring 2004

Assignment 2: Ray Tracing

Due on March 8 (Monday) at 11:59 PM


In this assignment you will implement a basic raytracer. To allow you to focus on the nuts and bolts of the actual ray tracing, you are provided with a host of data structures for managing the ray traced objects, linear algebra functions (vector and matrix objects and operations), a function for loading scene graph files into a prescribed node tree stucture, a BMP image file importer/exporter (for images and textures, etc), and a couple of supporting data structures for lights, materials, etc.

Additionally, a utility is provided to allow you to view your rayfiles. This will help you out in debugging your code and ensuring that the images come out looking as they should. The utility is implemented in OpenGL and so does not support recursive ray-casting and transparency, but at least for the first few parts of the assignment your image should agree with the image generated by the viewer. The viewer is available in both Linux and Windows formats (you might need glut32.dll if you're using Windows).

An overview of the code you will be using can be found here.

An overview of the .ray file syntax can be found here.

The code skeleton can be downloaded here (2.tar.gz,

What You Have to Do

The assignment is worth 20 points. The following is a list of features that you may implement. The number in parentheses corresponds to how many points it is worth.  Options in bold are mandatory.

By implementing all the required features, you get 13 points. There are many ways to get more points:

It is possible to get more than 20 points. However, as in the previous assignment, after 20 points, each point is divided by 2, and after 22 points, each point is divided by 4.

Getting Started

You should use the code available here (2.tar.gz,, as a starting point for your assignment. We provide you with: After you copy the provided files to your directory, the first thing to do is compile the program. If you are working on a Windows machine, double click on tracer.dsp and select build from the build menu. If you are developing on a UNIX machine, type make. In either case an executable called tracer (or tracer.exe) will be created.

How the Program Works

The program takes in to mandatory arguments, the input (.ray) file name and the output file name (.bmp). It is invoked from the command line with:
% image -src in.ray -dst out.bmp
Additionally, you can specify image height, image width, recursion depth and contribution limit as follows:
% image -src in.ray -dst out.bmp -width w -height h -rlim r -clim c
Feel free to add new arguments to deal with the new functionalities you are implementing. Just make sure they are documented.

What Has Not Been (Completely) Implemented

The following functions have not been completely implemented:

What to Submit

You should submit:

The writeup should be a HTML document called assignment2.html which may include other documents or pictures. It should be brief, describing what you have implemented, what works and what doesn't, how you created the art contest images and/or movies, and any relavent instructions on how to run your interface.

Make sure the source code compiles on the machines in Friend 017. If it doesn't, you will have to attend to a grading session with a TA, and your grade will suffer. Always remember the late policy and the collaboration policy.


Stay tuned for more hints.