COS 426:
Computer Graphics
Spring 2014


General | Syllabus | Assignments | Final Project


Overview

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


Running the Program

The ray tracing program, raypro, 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.

The raypro program reads scenes in a simple file format, which was created specifically for this course to provide the features required by this assignment -- a simple scene graph along with materials, lights, and cameras. We provide several example 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.

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

% 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.


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 ones marked in bold are required. The others are optional. Refer to the example web page to see images of inputs and outputs for several of these features.

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.



Getting Started

You should use the skeleton code in (cos426_assignment3.zip) as a starting point for your assignment. It contains a R3Scene class for reading and representing scenes (in R3Scene.h and R3Scene.cpp). It also contains useful classes for manipulating images and geometric primitives in the R2, R3, and jpeg subdirectories, just like in Assignment 2.

Compiling the code produces two executables: raypro and rayview (or raypro.exe and rayview.exe). raypro is the program that runs on the command line, and rayview provides a way for you to visualize scenes interactively.

To implement the ray tracing features listed above, you should add code to the appropriate functions within src/raytrace.cpp, add commands to the Makefile to test them, and edit sections of the writeup.html to present and discuss your results. You are welcome to create your own program arguments by editing raypro.cpp or rayview.cpp, but please do not change the program arguments already provided. You may also want to extend rayview.cpp to provide new visualizations to aid debugging, but please do not override or remove any of the commands in the existing user interface.



Submitting

You should submit your solution using one zip file named cos426_assignment3.zip via CS dropbox at this submission link. The submitted zip file should have the following internal directory structure:

cos426_assignment3/

The writeup.html file should be an HTML document demonstrating the effects of the features you have implemented and would like scored. You can start from the writeup.html provided with the distribution as a template -- simply add/delete sections to that HTML file for the features you implement.

The src directory should have all code required to compile and link your program (including the files provided with the assignment), along with a Visual Studio Solution file and a Makefile to rebuild the code. We will not attempt to grade assignments that neither build in Visual Studio nor with GNU Make under Mac OS X.

The Makefile should be a script containing the commands that generate all the meshes in the output directory that demonstrate features of your program you would like scored. It should run without crashing when started in the cos426_assignment3/ directory (i.e., it should be possible to delete all the mesh files in the output directory and then run make to regenerate them).

We will test your code on Linux 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 before submitting. Your Makefile should generate all the images in the output directory referenced by your writeup.

To save space, please submit images in .jpeg format (not .bmp or .ppm) and remove binaries and backup files from the src directory before submitting -- i.e., run make clean (under Linux or Mac OS) and execute "Clean Solution" on the "Build menu" in MS Visual Studio.

Note 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. Partial credit may not be assigned for code without comments.



FAQ

Answers to frequently asked questions: