Day 16, Halfway there
Fitting that the halfway point would be about reflections. Pagewise we’re more than halvway through the book, but I’m guessing that there will be plenty of things to do for the remaining 15 days. There’s still the going back and replacing the homebuilt algebra code with stdlib, if nothing else.
Reflections is just another ray to cast, from the point of reflection, and see what it hits. Whatever the reflection ray hits is blended into the Phong lighting. Recurse until satisfied.
Currently the recursion is aborted after a fix number of steps, but I’m pondering if it would be better so let recursion run until the contribution is small enough not to matter, and set a much higher fixed limit. That way barely reflective surfaces wont waste computation, but higly reflective surfaces, like a mirror maze, get the best possible fidelity.
Next related
Day 17, Transparency and Refraction
No new pixels today, because implementing transparency and refraction turned out to be quite a lot of work. So far I’ve made all the cases where nothing happens, and the refracted ray would be black.