COS 426:
Computer Graphics
Spring 2013


General | Syllabus | Assignments | Final Project


Assignment 3: Ray Tracing

Note: The makefile was updated April 7. See piazza post.

Due Tuesday, Apr. 9, 11:59 PM (part 1)
       Thursday, Apr. 18, 11:59 PM (part 2)

In this assignment you will create a simple ray tracing program. The program will read in a scene and output an image.


Getting Started

You should use the following skeleton code (cos426_assignment3.zip) as a starting point for your assignment. We provide you with several files, but you should mainly change raytrace.cpp.

The first thing to do is compile the program. Two executables will be created: raypro and rayview (or raypro.exe and rayview.exe). raypro is the program that does the ray tracing (just like imgpro from assignment #1), while rayview provides a way for you to visualize and process rayes interactively. Of course, you are welcome to extend rayview.cpp any way you wish to provide new visualizations, but please keep the semantics of the existing user interface.

The skeleton code is able to read scenes in a simple scene file format, This format was created to provide the features required by this assignment -- a simple scene graph along with materials, lights, and cameras. We provide several scenes in the input subdirectory of the zip file that you can use to test your program. We also provide some sample scenes created by students in past years, which may be fun to try. However, of course, you are not limited to these files -- you are encouraged to create your own files, either by hand, or with your programs from assignment #2. Note that it is very easy to combine multiple meshes and scenes in a single scene file using the "mesh" and "include" commands in the .scn file format, and it is convenient to size and position scene elements with the transformations provided by the "begin" and "end" commands.


How the Program Works

The user interface for this assignment was kept as simple as possible, so you can concentrate on the ray tracing issues. The raypro program runs on the command line. It reads a scene from a .scn file (the first program argument) and writes an image to a new file (the second program argument). The program allows a few program arguments that control features of the raytracer. For example, ...

% raypro in.scn out.jpg -width 128 -height 128

creates a 128x128 image (out.jpg) of the scene in in.scn. You are welcome to create your own program arguments by editing raypro.cpp. However, please do not change the program arguments already provided.


How to view a mesh and try commands interactively

To view a scene file named input.scn interactively (e.g., to see approximately what the raytraced image should look like), type:

rayview input.scn.

A window will pop up showing the scene from the camera include in the scene file (or a default, if there is none), and with lights like the ones in the scene file (or defaults, if there are none). You can drag the cursor with the left mouse button down to rotate the scene, with SHIFT-left-button to scale it (or the middle mouse button), and CTRL-left-button to translate it. You can also type F in the window to toggle display of faces, E to toggle display of edges, B to toggle display of the node bounding boxes, C to toggle display of the input camera, L to toggle display of lights, SPACE to print the current camera parameters (in a format that can be included in another .scn file), Q to quit, and F1 to save a screenshot in an image (in "imageN.jpg", for N=1,2,etc. increasing each time an image is dumped in the same session). Some of these commands are also available via a menu that pops up when the right mouse button is pressed. Of course, you are welcome to modify the source code in rayview.cpp in any way you want to produce debugging visualizations, but please keep the semantics of the existing user interface.


What You Have to Do

The assignment is worth 20 points. The following is a list of features that you may implement (listed roughly from easiest to hardest within each group). The number in front of the feature corresponds to how many points the feature is worth. The features marked with a green asterisk are required for the first deadline (April 9th). The ones marked in bold are required for the second deadline (April 18th). The others are optional. Refer to the example web page to see images of inputs and outputs for several of these filters.

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, after 20 points, additional points will incur diminishing returns, as on past assignments.


Submitting

* This assignment has a split deadline. On the first due date (April 9th), please submit writeup1.html with the features marked with a green asterisk completed (8 points). On the second due date, please submit both an unchanged writeup1.html and new writeup2.html with 20 points completed. While only the first eight points marked with a green asterisk must be completed by the first due date, we strongly encourage you to start your implementation on more advanced features before then.

Please submit a single .zip file named [your NetID]_cos426_assignment3.zip containing:

We remind you that you are expected to use good programming style at all times, including meaningful variable names, a comment or three describing what the code is doing, etc. We will test your code by running make in your src/ subdirectory, followed by make in the main assignment directory to create the output images. Please ensure that your code builds/runs in this way. Please make sure that your submitted output folder contains all of your results and show them in the writeup.

Please see these slides and the assignments page for general notes on submitting your assignments, including the late and collaboration policies.

The Dropbox link to submit part 1 of your assignment is here and part 2 here.