Programming assignment #1 - Basic ray tracer

CS 348B - Computer Graphics: Image Synthesis Techniques
Spring Quarter, 1996
Marc Levoy
Handout #7


Due Monday, April 22, 11:59pm


The project for this quarter is to write a ray tracer. In assignment #1, you will assemble the basic building blocks for recursively tracing rays through scenes composed of triangles and spheres. A secondary goal of this assignment is to familiarize you with the SGI graphics workstations and the software tools that you will use during the remainder of the quarter.

The front end

The front end for your ray tracer will consist of i3Dm, a modeling program written by Silicon Graphics, and Composer, a scene manipulation package based on Inventor, Silicon Graphics's 3D graphics toolkit. i3Dm allows you to interactively define simple 3D models. Composer allows you to interactively assemble scenes composed of boxes (constructed from triangles), spheres, and models imported from i3Dm (which Composer converts into triangles). Composer also allows you to select viewing parameters, define directional or point light sources, and specify reflectance properties for each object in the scene. For scenes of modest complexity, Composer provides real-time shaded renderings as feedback.

Your renderer

Your renderer will be a standalone C (or C++, if you prefer) program that runs alongside Composer. Using our X support package, you will construct a menu containing a display window and any number of Motif sliders and buttons. The latter allow you to interactively control rendering parameters not supported by Composer, of which you may have many by the end of the quarter. Your menu should include buttons for retrieving the current scene geometry, shading, and viewing parameters from Composer and for saving the rendered image in a file. We provide the routines for performing the actual file I/O. You should also provide a slider for controlling image size. Finally, you should provide a "Render" button. When hit, you will render the scene using your ray tracer and display the resulting image in the display window. Don't expect your ray tracer to run in real time.

Required functionality

  1. Read a scene description describing the camera, lights and a set of objects with associated material properties from a file created by Composer.
  2. Cast rays into the scene to simulate the image formed by a pin-hole camera. One ray per pixel is sufficient for now.
  3. Intersect rays with the geometric primitives. Don't worry about speed yet.
  4. Implement Whitted's illumination model (FvDFH, eq. 16.55), which includes ambient, diffuse, and specular terms for each unshadowed light source as well as reflection and refraction terms. This will require you to trace rays towards each light source and recursively trace reflected and refracted rays. You only need to handle directional and point light sources, i.e. no area lights, but you should be able to handle multiple lights.
  5. Write an image file containing your synthetic image.

Programming hints

Paul Heckbert's chapter in Andrew Glassner's An Introduction to Ray Tracing gives a good overview of how to write a ray tracer. Feel free to copy his organization and examples. Using his nomenclature, Composer provides your SceneRead routine and defines your Camera and Display data structures. You must write the Screen, Trace, Intersect, and Shade routines. If you're having trouble converting pixel positions into ray directions, see Glassner's A Simple Viewing Geometry in Graphics Gems II (handout #8). To render triangles and spheres, you will need two intersection routines. See sections 2 and 3 of Haine's chapter or section 15.10.1 of Foley, van Dam, et al. Also feel free to use Heckbert's ray-sphere intersection code (in Glassner).

The support software you need for this project is contained in /usr/class/cs348b. (A tarred and gzipped copy is available in ftp://www-graphics/pub/courses/cs348b/). Look at the README file and the software and other README files that it references. To facilitate debugging and grading, please use the mapping from Composer's material attributes to the terms in Whitted's illumination model that is suggested in README.composer.

Design your software to be modular so that you can extend it. In programming assignment #2, you will add an acceleration scheme. In programming assignment #3, you will add one or more extensions of your own choosing.

Submission requirements

Your ray tracer should be able to handle the three test scenes test1.out, test2.out, and test3.out in the directory /usr/class/cs348b/proj1/tests. If you want to look at these scenes in Composer, load the corresponding .iv files. You should run the ray tracer on those scenes and save the images it produces. In addition, you should create two more scenes of limited complexity to test your system. Save those scenes and the images produced. The majority of your grade will be based on your results, although we will look briefly at your code to make sure it is plausible.

When you have completed your assignment, make a copy of your code and the test scenes and associated images in a directory called project1 in your home directory. Write a README file with enough information so that we know what is there. Then follow the instructions in /usr/class/cs348b/README.submit to complete your submission. Don't touch the files in that directory after the due date.


[email protected]
Copyright © 1996 Marc Levoy
Last update: Monday, 20-May-1996 15:33:33 CDT