CompSci 344
Spring 2015
Computer Graphics

Ray Tracer

Write a ray tracer that displays basic shapes, lights, and materials. Ray tracing is, in some sense, the most natural way to generate images. By generating and casting rays, the ray tracer is able determine what color we would see if we looked in some direction from some point of view. Within the accuracy of the scene and shading models and with enough computing time, the images produced by a ray tracer can be physically accurate and can appear indistinguishable from real images. The ray tracer you are required to write for this assignment will not be able to produce physically accurate images since it is very basic, containing just the key elements regarded to be a ray tracer.

The basic idea behind ray tracing is to model the movement of photons as they travel along their path from a light source, to a surface, and finally to a viewer's eye. Tracing forward along this path is difficult, since it can be unclear which photons will make it to the eye, especially when photons can bounce between objects several times along their path (and in unpredictable ways). To simplify the system, these paths are computed in reverse; that is, rays originate from the position of the eye. Color information, which depends on the scene's light sources, is computed when these rays intersect an object, and is sent back towards the eye to determine the color of any particular pixel.

A ray tracer computes images in image order, meaning that the outer loop visits pixels one at a time. (In our framework the outer loop is found in the class RayTracer). For each pixel it performs the following operations:

Minimally, your ray tracer must support:

Your ray tracer will read files in an XML file format and output PNG images. All data regarding the scene to be traced should be read from the given data file. You do not need to worry about malformed input, either syntactically or semantically. For instance, you will not be given a sphere with a negative radius or a scene without a camera. Additionally, you do not have to worry about the camera being inside an object.

You will be given a coding framework to spare you from the mundane details of GUI, I/O, vector arithmetic, etc. However, you will need to complete all of the methods of the ray tracer. Feel free to create whatever new classes or methods you think are necessary. In the end, if your program works, and is understandable, you will receive full credit.

Extra Credit

There are many possible additions to the basic ray tracer. You can earn bonus points with extremely creative or artistic solutions. Make sure that you mention your assumptions, extra features, and how to run your program (especially with regard to command line arguments) in your README file.

To get you started, here are some extra credit ideas:

These features will require understanding the code framework and determining how to modify it in places not marked by a TODO comment.

Resources