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 Goal is to reproduce the following Whitted, - - PDF document
So You Want to Write a Ray Tracer Checkpoint 6 Refraction Ray Tracing Assignment Goal is to reproduce the following Whitted, 1980 1 Ray Tracing Assignment Seven checkpoints 1. Setting the Scene 2. Camera Modeling 3. Basic
Whitted, 1980
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
If negative – total internal reflection
2 2 2 i i
) ) n d ( 1 (
n ) n) n(d d ( t
t t
η η η η
−
=
i
t
η
i
θ
t
θ
η Index of refraction Normal vector
i
public Vector3f faceForward (Vector3f A Vector3f B) { // For acute angles, dot product will // be positive if (A.dot(B) >= 0) return A; // Obtuse angle, reverse the first vector Vector3f V = new Vector3f (A); V.scale (-1.0f); return V; }
Sphere1 – front Color (all) = white Ka = 0.075 Kd = 0.075 Ks = 0.2 Ke = 20.0 Kr = 0.01 Kt = 0.85 Sphere2 – rear Color (amb/diffuse)
(0.7, 0.7, 0.7)
Color (spec) = white Ka = 0.15 Kd = 0.25 Ks = 1.0 Ke = 20.0 Kr = 0.75 Kt = 0.0