1
So You Want to Write a Ray Tracer
Checkpoint 6 – Refraction
Ray Tracing Assignment
Goal is to reproduce the following Whitted, 1980
Ray Tracing Assignment
Seven checkpoints
Setting the Scene Camera Modeling Basic Shading Procedural Shading Recursive Ray Tracing – Reflection Recursive Ray Tracing – Transmission Tone Reproduction
Ray Tracing Assignment
Seven checkpoints
Setting the Scene Camera Modeling Basic Shading Procedural Shading Recursive Ray Tracing – Reflection Recursive Ray Tracing – Transmission Tone Reproduction
Refraction
Perform recursive ray tracing by
considering reflection and refraction
Parameters to add:
For each object
kr, kt – reflection and transmission constants kt ≠ 0 for this checkpoint Index of refraction (example 0.95)
Recursive Ray Tracing
color illuminate (ray, depth) find closest intersect if (!intersection) return background color else spawn shadow ray retcolor = local illumination if (depth < MAX_DEPTH)
if (kr > 0) spawn reflection ray retcolor += kr * illuminate (reflect ray, depth+1) if (kt > 0) spawn transmission ray retcolor += kt * illuminate (trans ray, depth +1)
return retcolor