[an error occurred while processing this directive] COS 526, Fall 2004: Programming Assignment 3 [an error occurred while processing this directive]

COS 526 - Advanced Computer Graphics

Fall 2004

Course home Outline and lecture notes Assignments

Programming Assignment 3: Path Tracer

Due Tuesday, Dec. 7

For this assignment, you will implement a Monte Carlo path tracer. Your program must do the following:

  1. Randomly generate multiple primary rays for each pixel.
  2. Trace the rays into the scene (see CS 426 notes for details).
  3. Terminate tracing paths with Russian roulette (see [Arvo 90]).
  4. At each intersection, generate two secondary rays: one to estimate the direct illumination (i.e., a ray to a light source), and one to estimate indirect (specular and diffuse) illumination. The latter ray should be generated using importance sampling according to a Lambertian + Phong BRDF. Be careful to weight these terms correctly when combining them.

Getting Started

You may begin with any ray tracing code you may have. Alternatively, there is code available here as a starting point for your assignment (courtesy Tom Funkhouser). To allow you to focus on the nuts and bolts of the actual Monte Carlo path tracing, you are provided with a libaries (in the "pkgs" subdirectory) that provide a host of data structures for basic math and data manipulation operations (pkgs/RNBasics), 2D geometry (pkgs/R2Shapes), 3D geometry (pkgs/R3Shapes), and computer graphics rendering (pkgs/R3Graphics).   "Documentation" for each C++ class is provided in the "docs" subdirectory, and example programs appear in the "apps" subdirectory.  In particular, you should start by editing the code in apps/rdraw.C and/or apps/monte/rmonte.C, which implements simple ray casters and provide a good initial structure for your program.

After you copy the provided files to your directory the first thing to do is compile all the existing code. If you are developing on a Windows NT machine, running Microsoft Visual C++, from the MS-DOS prompt, type:

% "c:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32"
% nmake

Then, you can begin editing the code in apps/monte/monte.C.  it is recommended that you develop incrementally (implement in small steps, and test each step separately) and that you do most of your testing on simple, well-designed examples (simple scenes, small images, few paths per pixel, stresses feature of interest, etc.) because execution/debugging times will be quite long otherwise.

The code provides a function (R3ReadRayFile in R3Graphics/R3Io.C) to read simple scene files.  The syntax of the .ray file format is described here.  Those of you who took CS426 will recognize it as a subset of the .ray file format used for the ray tracing assignment (with a few minor changes).  Most significantly, groups with arbitrary transformations are not included, which makes intersection and sampling of rays much simpler. A repository of sample .ray files will be provided here.


Please make your writeup and code accessible via the web, and send the URL to smr@princeton.edu with "COS526" in the subject line. Please see the general notes on submitting your assignments, as well as the late policy and the collaboration policy.

Last update 29-Dec-2010 12:01:30
smr at princeton edu