Ray Tracer Checkpoint 3: Basic Shading
Assigned: December 15, 2010
Due:
January 5, 2011
See assignments overview page for general
information.
Introduction
The ray tracer programming assignment is divided into seven checkpoints:
- Setting the scene
- Camera modeling
- Basic shading
- Procedural shading
- Recursive ray tracing - reflection
- Recursive ray tracing - transmission
- Tone reproduction
This is checkpoint #3: "Basic shading".
Objective
Using your program from checkpoint #2 (without extras), the task for this
assignment is to add Phong Illumination to your ray tracer. On intersection,
rather than return the color of the object you hit, you must calculate the color
at the intersection point using the Phong Illumination model. All the relevant Phong equations can be found in the CG2 lecture notes
for Checkpoint 3 (on myCourses).
Recall that the Phong model:
- Introduces specular reflections
- Viewer direction becomes more important
- Three lighting components:
- Ambient (background light, ka)
- Diffuse (Lambertian reflection, kd)
- Specular (mirror-like reflection, ks, ke)
You will need to add the following things to your program:
- To your world:
- To your light source:
Color (r,g,b) to give intensity and chroma
- To each object:
- Phong parameters
- Ambient (background light, ka)
- Diffuse (Lambertian reflection, kd)
- Specular (mirror-like reflection, ks)
- Exponent (controls size of specular highlight, ke)
- Object "color''
- Ambient/diffuse color (basic color of object)
- Specular color (color of specular highlight; usually, white)
You'll need to work with the following vectors:
- N - Normal (get from the intersection calculation)
- S - Source (get by subtracting intersection point from light position)
- R - Reflection (from incoming direction and normal vector)
- V - View (subtract intersection point from camera position)
To apply the Phong model, if there is an intersection,
- Calculate the ambient component
- Spawn a shadow ray from the intersection point to the light source
- If the shadow ray reaches the light before hitting any other object,
- Obtain N, V, S, and calculate R
- Calculate diffuse and specular components
- Add to the ambient component
- Return the result color
What to Submit
To submit your solution, do the following before midnight on January 6,
2011:
- Place an image on the web site showing the results of your work (your
rendering, or a screenshot of your rendering, etc.)
- Send me email to let me know you have posted your results
As it is extremely important to continue to make progress as the course
progresses, late deliverables will be penalized 10% for each day late.
There is an exception to this rule: if you anticipate any problems with meeting
deliverable deadlines, see me well in advance (ideally, at least one week) of
the deadline that might be missed, and we can attempt to work out alternate
arrangements.
Extras
Recall that you must do at least four "extras" in order to achieve the full
100 points for the programming assignments. "Extras" are worth five points
each; this assignment has two possible "extras":
- Add support for multiple light sources
- Implement another illumination model
- Phong-Blinn, Strauss, etc.
If you choose to do an extra, put multiple images on your web site:
- One showing your results without the "extra"
- Another image showing the results of the "extra"
Notes
As before, modular design will greatly simplify future modifications to your
code.