Rendering Techniques Assignment 2:

Writing a Recursive Ray Tracer

Assigned: Monday, February 24, 2003
Due:  Monday, March 17, 2003

Overview

For this assignment, you will extend your ray casting program to perform recursive ray tracing. In addition to performing local illumination of spheres, the program will spawn reflection and transmission rays at each ray/sphere intersection. These rays gather new illumination information about the scene and the results are combined with the local illumination to produce the final color that the ray returns.

You may find it useful to review Foley, van Dam, Feiner, and Hughes, section 16.5.2 as well as the introductory section of 16.12.

Program Description

Like the ray casting program, your ray tracing program will read a scene description from an input file and produce a PPM-format image file as output. This new program should be invoked by the following command:
[java] raytrace <scene description filename> <image output filename>
The MAX_BOUNCES parameter in the input file specifies the maximum level of recursion for your ray tracer. If this parameter is set to zero, your program should function as a ray caster. Otherwise, your shading calculations will now call the ray tracing routine recursively for a reflection ray and a transmission ray. Each of these rays returns a color to be combined with the local illumination to determine the color returned by the current ray. The specular coefficient and color of the current surface indicate how much of the reflection ray's color may be returned by the current ray, and similarly for the transmission ray. The direction of the reflection ray is just the incident ray mirrored about the normal. The direction for the transmission ray may be computed as described in FVD 16.5.2. In the case of a total internal reflection, simply have the transmission ray return no light.

Recall that the index of refraction determines how much the light is bent during transmission.  Assume the index of refraction for the empty space (“air”) is 1.0.  Assume that transparent spheres are solid (not hollow).  Further assume that transparent primitives do not intersect each other (i.e. contain one another or otherwise overlap). That would require a more complex algorithm for determining the index of refraction of the current material.  Assume that light along the shadow rays is not refracted, but attenuates (filters) the color of the light in a frequency-dependent fashion according to the transmission coefficients and colors of the spheres between the surface and the light source.

A few interesting points to consider. Notice that our index of refraction model is not frequency dependent (all light is bent the same way). Also, our method of filtering the light refracted through the spheres is perhaps more surface-like than solid-like. For light to pass through a sphere, it follows along two transmission rays (e.g. rays T2 and T1 in Figure 16.54 in FVD). Each of these rays is filtered by the object's transmission coefficient and color. Thus the light has actually been filtered twice to pass through a single object. Do not attempt to correct this - simply implement it in the straightforward fashion described in FVD. The Watt/Watt description of transmission rays seems a bit different from FVD. In Watt/Watt, T1 and T2 are considered a single transmission. This avoids the previous anomaly, but it also differs in that it leaves out the local illumination and reflection ray at the junction where the ray exits the surface. It's not clear that either of these methods is more correct, so implement your recursion as described in FVD.

For your reference, a few other indices of refraction:

Water 1.33
Glass  1.52
Dense glass 1.66

As with the first assignment, this assignment includes a sample scene description and the corresponding rendered image. Like the previous sample scene, this sample provides only one small test of your program's functionality. You should test your program on this file as well as many other test cases you devise to ensure that your program functions properly in all tricky circumstances. The same test executables I gave your for the first assignment should work for this assignment.

Deliverables

Submit your program as a single .zip file on the submission page. Include the following: Again, please follow the above procedure to turn in the assignment to avoid delayed grading or reduced grades.

Scene Description Format (extension .rt2)

Numbers in angle brackets are real numbers, in square brackets are integers
Naturally, the brackets do not appear in the actual file (but the colons do).
Blank lines and white space should be ignored
Lines with a ‘#’ as the first character are comments and should be ignored.
Colors should be specified in the range [0.0, 1.0]
Angles should be in degrees, and refer to the full angle (as opposed to the half angle)
 
# comment lines start with # and may appear anywhere
RESOLUTION: [x resolution] [y resolution]
FIELD_OF_VIEW: <full x field-of-view>
BACKGROUND: <red> <green> <blue>
MAX_BOUNCES: [maximum recursion level]
NUM_LIGHTS: [number of lights]
LIGHT
 POSITION: <x> <y> <z>
 DIRECTION: <x> <y> <z>
 INTENSITY: <red> <green> <blue>
 EXPONENT: <exponent>
 CUTOFF: <angle>
ENDLIGHT
LIGHT
ENDLIGHT
LIGHT
ENDLIGHT
#in other words, one LIGHT…ENDLIGHT block for each light
NUM_SPHERES: <number of spheres>
#similarly, one SPHERE…ENDSPHERE block for each sphere
SPHERE
 CENTER: <x> <y> <z>
 RADIUS: <radius>
 DIFFUSE_COLOR: <red> <green> <blue>
 DIFFUSE_COEFFICIENT: <coefficient>
 SPECULAR_COLOR: <red> <green> <blue>
 SPECULAR_COEFFICIENT: <coefficient>
 SPECULAR_EXPONENT: <exponent>
 TRANSMISSION_COLOR: <red> <green> <blue>
 TRANSMISSION_COEFFICIENT: <coefficient>
 REFRACTION_INDEX: <index of refraction>
ENDSPHERE
SPHERE
ENDSPHERE
SPHERE
ENDSPHERE
 

Final Words of Encouragement

The good news is that this program should be significantly easier than the first assignment if your current program is well-structured. Of course, you are responsible for ensuring that your current program functions correctly as a ray caster as per the grading comments you will receive on your first assignment. Let us know if you are having problems you can't get past (of course, sooner is better than later).

Home
February 24, 2003