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.

balls -s 3 with reflection, shading and shadows

The Assignment

For this assignment, you will add 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
surface name
    ambient Ar Ag Ab
    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 of the surface ambient, and for each unshadowed light source, 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).

For diffuse, use light.intensity * surface.diffuse * dot(N,L), where L is a unit vector pointing from the surface to the light position. For specular, use light.intensity * surface.specular * dot(N,H)surface.specpow

To help with your development and debugging, here are the individual components

Diffuse Specular Diffuse + Specular Reflection All three
traced image for mount -s 2 -r 8 traced image for mount -r 8

634 only

Also implement refraction. You can use mount.ray and mount-2.ray for testing (the result of running the mount spd program with the default -s, and with -s 2).

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

Also include an assn1.txt file at the top level of your repository telling us about your assignment. Tell us what works, and what does not. 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 full 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, generated images, zip files, libraries, or other non-code content.