Before you start

This assignment builds on the previous one. If yours worked, I strongly recommend using your own code as a starting point for this assignment. If you were not able to get the first part of your ray tracer working, I will provide access to sample code after the late submission deadline for assignment 1. You are free to either use this code to figure out what was wrong with your assignment, or use it as a base for this one.

teapot with reflection, shading and shadows

The Assignment

For this assignment, you will add normal interpolation, mirror reflection, and diffuse and Blinn-Phong direct illumination with shadows to your ray tracer.

In assignment 1, you needed to track the color at the closest intersection. For this assignment, you will also need to track the surface normal, intersection location, and these additional ray file parameters:

maxdepth bounces
cutoff threshold
light intensity point Lx Ly Lz
surface name
    diffuse Dr Dg Db
    specular Sr Sg Sb
    specpow e
    reflect Kr

You will want two ray tracing functions. The first, commonly called probe or anyhit, is used for shadow testing. It should return true if there is any intersection between the start and end of the ray, and does not need to necessarily find the closest intersection or continue intersection testing once it has found a hit. The second, commonly called trace, should return the overall color from recursively tracing into the scene along a ray. That is, it should find the closest intersection along the ray, and return a color that is the sum of the direct illumination and the reflected color scaled by the surface reflection coefficient. The direct illumination is the sum for each unshadowed light source of the Lambertian diffuse and Blinn-Phong specular. The reflected color is the result of a recursive call to the trace function for a ray starting at the surface intersection point pointing in the reflection direction. The recursion should stop when the number of bounces reaches the maxdepth (default 15), or the product of the reflection coefficients along the ray is less than the cutoff (default 0.002).

To help with your development and debugging, here are the effects of each components

Diffuse Diffuse + Specular Diffuse + Specular + Reflection

Extra credit

For up to 5 points of extra credit, make your ray tracer run faster by parallelizing it. For 10 points of extra credit, make it run faster with an acceleration structure, either BVH or spatial partitioning. You can do either parallelization or acceleration structure, or both for a possible total of 15 points extra credit.

teapot with depth of field aperture 0.5

634 only

Also implement antialiasing and depth of field. You will need to add an aperture line to a ray file to add depth of field, and also add support for the samples keyword (and potentially add or change that line of the file as well). Ignore the jitter or nojitter options for sample, and always randomize the sample locations.

What to turn in

Turn in this assignment electronically by pushing your source code to your class git repository by 11:59 PM on the day of the deadline and tagging the commit assn2. Do your development in the trace directory so we can find it (we'll be able to use the assn1 tag to find that version for grading, so you can just continue development in the same directory).

Commit one or a few sample ppm images in your trace directory so we can see your results before running.

Also include an assn2.txt file at the top level of your repository telling us about your assignment. Tell us what works, and what does not. Describe your sample image files by name so we can know what they are. Also tell us what (if any) help you received from books, web sites, or people other than the instructor and TA.

You must make multiple commits along the way with useful checkin messages. We will be looking at your development process, so a complete and perfectly working ray tracer submitted in a single checkin one minute before the deadline will NOT get credit. Individual checkins of complete files one at a time will not count as incremental commits. Do be sure to check in all of your source code, but no build files, log files, zip files, libraries, or other non-code content.