February 2019
Intermediate to advanced
292 pages
6h 55m
English
The final bit to actually render the shadows requires a small change to your shade_hit function from Building a World. You need to check whether the point is in shadow or not, and then pass that state to your lighting function.
Add the following test to those that you wrote for the shade_hit function. To demonstrate the case where some object is shadowing the point of intersection, it creates a world and two spheres, and positions a light so that the second sphere is in the shadow of the first. Then, a ray and an intersection are created such that the point of intersection is in the shadow. The shade_hit function should return only the ambient color of the second sphere in this case.
| | Scenario: shade_hit() ... |
Read now
Unlock full access