CS 3451, Spring 2013

Homework 3: Ray Tracing

Due: 11:55pm, Monday, March 25, 2013

Objective

The goal of this project is to write a ray tracing renderer. Your program should be able to read scene data from a file according to a defined scene description language. From this, your program will then render an image of the scene and write out the image to a file. In this project we will use just two geometric primitives: spheres and triangles. We will implement shadows and reflection, but not refraction.

Scene Description Language

Note on color specification: Each of the red, green, and blue components range from 0.0 to 1.0.


Code Provided

All the provided source code that you will need for this assignment can be downloaded here: ray_parser.zip. We have supplied some utility functions that you should use to complete this assignment. A interpreter routine is provided so that you do not have to write a parser for the scene description language. See below for more details on these routines.


Scene Files

In the directory "data" are several test scenes that are described by .cli files. Also in that directory are the images that should be created by these scene files. The file "t0.cli" is perhaps the most simple image, and you might use this scene as a starting point. Pressing keyboard keys 1-9 and 0 calls the 10 test samples respectively.
Note: Don't change the directory name or processing won't reconize those files.

Sample Results:


Suggested Approach

It is probably best to begin by making small changes to the "ray_parser.pde" program to see how to add new commands to the CLI interpreter. After you feel comfortable with this, then you can make dummy routines for each of the commands that your ray tracer should understand. Then replace each of the dummy routines with real code and you will be done! :-)

Once the shell of the program is ready, we suggest creating the main loop that creates the primary rays (those from the eye). Start by printing out the information about these rays to make sure that the numbers make sense. Once you've got this loop working, then start on the ray/sphere intersection routine. Don't bother shading the sphere correctly at first-- just color it anything other than the background color. Once you've got a round object on the screen, then work on the shading of the sphere. Finally, work on ray/triangle intersection.


Authorship Rules

The code that you turn in must be entirely your own. You are allowed to talk to other members of the class and to the instructor and the TAs about high-level questions about the assignment. You may not, however, use code that anyone other than yourself has written. Code that is explicitly not allowed includes code taken from the Web, from books, or from any source other than yourself. The only exception to this rule is that you should use the parser routines that we provide. You should not show your code to other students. If you need help with the assignment, seek the help of the instructor or the TAs.


Development Environment

You must use the Processing language which is built on Java. The best resource for Processing language questions is the online or offline Processing language API (found in the "reference" subdirectory of the Processing release).


What To Turn In

Compress the whole folder (not merely the files within the folder) into a zip archive submit them to T-square. The zip archive should be included as an attachment. The filename should be "last_first_p3.zip", so Greg Turk would create "turk_greg_p3.zip" for his homework 3. When unzipped, it will produce the folder "ray_parser" containing the file "ray_parser.pde", a directory "data", and other .pde files you created.