The Plan
The goal was to make surfaces reflective based on a coefficient of reflection that each surface will have.The easiest way to do this was to have each surfaces' material (or texture, as of the last checkpoint) store the coefficient of reflection.
The actually reflection is then implemented using recursion. The basic algorithm is as follows:
- Cast out a ray
- Check for surface collision
- If no collision, use background color (black)
- If collision
- Calculate normal illumination color
- Determine reflection ray
- Start over again, but with reflection ray
Results
Basic - Reflective surface |
The actual algorithm is extremely straightforward, simple to implement, and looks awesome. However, I still struggled for way too long with the blue sphere being in the reflection; turns out my sphere-ray collision detection was broken.
Also, it may be difficult to see, but please note that the specular highlight no longer shows up in the shadowed areas. This, of course, is a triumph. I have to make a note here; huge success. It's hard to overstate my satisfaction.
No comments:
Post a Comment