Chapter 8
Shadows

Your ray tracer is really starting to come together. Just look at it! You’ve got spheres, realistic shading, a powerful camera, and a world that supports scenes with many objects.

It’s a pity those objects don’t cast shadows, though. Shadows add a delightful dash of realism to a scene. Check out the following figure which shows the same scene both with and without shadows:

images/shadows/shadows-comparison.png

Your brain uses those shadows as cues for depth perception. Without shadows, the image looks artificial and shallow, and that will never do.

Thus, the time has come to add shadows, and the best part is that you’ve already written most of the infrastructure to support this. The first step is to adjust your lighting function to handle the case where a point is in shadow. Then you’ll implement a new method for determining whether a point is in shadow or not, and last you’ll tie those pieces together so your ray tracer actually renders the shadows.

Let’s dig into it!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.193.172