First off, thanks for the pointers! I'll certainly look into those when I have a chance.
I have no idea why the file was corrupted. I'll re-archive and update the file on the server.
You're right about the multiple intersections I indeed sort them by distance. But I forgot to return only the first two elements (needed for entering and exiting a shape for refraction). I'll fix that.
Ugh - I used t as a var? I should have known better than that. Must be remnants of my terse C coding style :)
> But I forgot to return only the first two elements (needed for entering and exiting a shape for refraction).
Strange; I would have thought you needed only one intersection, because my mental model for refraction would be:
|
-----+-------
\
\ <-----new ray
--------+----
|
|
viewer
So you really need only one intersection - the nearest, because the second intersection wouldn't really be aligned to the refraction ray. But then I haven't read the book you are reading.
Basically at each intersection point I'd expect to split into three rays: a reflection ray (cross product to the normal), a refraction ray (if at least partially transparent) and a shadow ray (towards any source(s) of light).