Quiz: shadows, mirrors and glass
Before this unit: Rays from the camera, and where they hit (previous unit); Day 52: 3D graphics.
See also: Day 46: Colour; Day 5: Deconvolution; Day 55: How GPUs work.
Short questions to test your understanding. Try each on paper first, then open the answer. Angles are measured from the surface normal; air has n = 1, water 1.33, glass 1.5.
Q1. A ray tracer renders a floor covered in dark speckles, although nothing is between the floor and the light. What is going on, and how do you fix it?
Where does the shadow ray start, and what does floating point do to that point?
Shadow acne. The computed hit point lies a tiny bit below the floor for some pixels (rounding), so their shadow ray hits the floor itself at t \approx 10^{-7} and the pixel is wrongly in shadow. Start the shadow ray at \mathbf p + \varepsilon\mathbf n (or ignore hits with t < \varepsilon). Not too large an \varepsilon, or light leaks under thin objects near the surface.
Q2. A ray hits glass (n = 1.5) from air at 30° from the normal. Is the refracted ray closer to or farther from the normal? Compute its angle.
n_1\sin\theta_1 = n_2\sin\theta_2.
Closer (into the denser medium): \sin\theta_2 = \sin 30°/1.5 = 0.333, \theta_2 = 19.5°.
Q3. Light travels inside water towards the surface at 60° from the normal. What happens? And at 40°?
The critical angle for water → air is \arcsin(1/1.33).
The critical angle is 48.8°. At 60° there is no refracted ray: total internal reflection, all the light stays in the water. At 40° the light leaves, bent away from the normal: \sin\theta_2 = 1.33\sin 40° = 0.855, \theta_2 = 58.7° (and a few percent are reflected).
Q4. Why does a glass window reflect almost nothing when you look straight at it, but act like a mirror when you look along it at a grazing angle?
Fresnel: how does R depend on the angle?
The Fresnel reflectance is R_0 = ((1 - 1.5)/(1 + 1.5))^2 = 4\% head-on and grows to 1 as the angle approaches 90°. Straight on, 96 % of the light passes through; at grazing angles most of it is reflected.
Q5. A glass bead (n = 1.52) is placed in immersion oil (n = 1.518). Why is it nearly invisible?
What do reflection and refraction depend on?
Both depend on the ratio n_1/n_2, here almost 1: the rays hardly bend (Snell) and almost nothing is reflected (R_0 = ((1.518 - 1.52)/(1.518 + 1.52))^2 \approx 4\cdot10^{-7}). With nothing reflected or deflected, the bead’s edges cannot be seen.
Q6. In a Whitted ray tracer, a pixel sees a glass ball. Every hit on glass spawns a reflected and a refracted ray. How many rays does the pixel’s tree have at most with a depth limit of 3 (shadow rays not counted)? Why is the real number usually much smaller?
A full binary tree; rays that miss everything stop.
1 + 2 + 4 + 8 = 15. In practice many branches leave the scene (hit the sky) or hit a diffuse surface that does not split; and branches whose weight (the product of the R and 1 - R factors) drops below a cut-off are not traced.
Q7. In a Whitted-rendered image, the shadow behind a glass ball is completely black, while a real glass ball on a table throws a bright spot of focused light into its shadow. Why does the ray tracer miss it?
Which ray decides whether the table point is lit?
The table point sends a shadow ray straight towards the point light; it hits the glass ball and counts as blocked. The real light reaches that point by refracting through the ball, along a bent path that no shadow ray follows. Such focused light (a caustic) needs light from all directions to be gathered: path tracing, unit 4.
Q8. (math) Show that the mirror direction \mathbf r = \mathbf d - 2(\mathbf d\cdot\mathbf n)\mathbf n has the same length as \mathbf d and makes the same angle with the normal (on the other side).
Compute \mathbf r\cdot\mathbf n and \mathbf r\cdot\mathbf r, using \mathbf n\cdot\mathbf n = 1.
\mathbf r\cdot\mathbf n = \mathbf d\cdot\mathbf n - 2(\mathbf d\cdot\mathbf n) = -\mathbf d\cdot\mathbf n: the same angle with the normal, on the other side. \mathbf r\cdot\mathbf r = \mathbf d\cdot\mathbf d - 4(\mathbf d\cdot\mathbf n)^2 + 4(\mathbf d\cdot\mathbf n)^2 = \mathbf d\cdot\mathbf d: the same length.