This is an archive of a past semester of this course. Go to the current semester.
Project 3-2: Ray Tracing Part 2

Due Date

Mon March 19th, 11:59pm


You will add more complicated materials, environment lights, and depth of field to your ray tracer

Project Parts

You'll also want to read these articles:

Using the program

Accept the assignment through the link posted on piazza, and clone from your private repo using the command:


As before, use cmake and make inside a build/ directory to create the executable (how to build and submit).

You may wish to consult the getting set-up portion as well for part 5 so that you may download any dependencies you require now for offline work later on.

Please consult the project 3-1 spec for details on the user interface. Here are some old and new command line flags you'll want to pay attention to:

  • -e some_map.exr loads an environment light .exr image file (part 3)
  • -b 1.23 sets the lens radius to 1.23 (part 4)
  • -d 4.56 sets the focal distance to 4.56 (part 4)

As well as two new keyboard commands:

  • "k" | "l": Increase/Decrease the camera lens radius
  • ";" | "'": Increase/Decrease the focal distance

Also please use the "cell render" mode to debug, where you can interactively click and drag to select a small region of the screen to be rendered. Press c (after pressing r) to toggle this mode in the GUI.

Integrating the new code

In order to get this new version of pathtracer up and running (even to run cmake), you will need to copy over the version of these files you filled in for your previous assignment (make sure you copy the entire file):

  • Part 1: triangle.cpp, sphere.cpp
  • Part 2: bvh.cpp, bvh.h, bbox.cpp

Additionally, you will have to copy these specific functions into the new pathtracer.cpp file:

  • PathTracer::estimate_direct_lighting_hemisphere
  • PathTracer::estimate_direct_lighting_importance
  • PathTracer::zero_bounce_radiance
  • PathTracer::one_bounce_radiance
  • PathTracer::at_least_one_bounce_radiance
  • PathTracer::est_radiance_global_illumination
  • PathTracer::raytrace_pixel

and these functions into bsdf.cpp

  • DiffuseBSDF::sample_f
  • DiffuseBSDF::f

and this function into camera.cpp

  • Camera::generate_ray

Do not overwrite the rest of these three files!

Final Note

When you finish Project 3-2, you can basically render anything, so show it off! Make some fancy scenes and materials, and play with the lens! Again, be creative!