Chapter 12Cubes

Reflections and refractions were huge, and you totally nailed them! Your scenes are looking more realistic than ever. In this chapter, you’re going to increase the scope of what’s possible by adding a new primitive shape: the cube.

Check it out. Here’s a scene rendered entirely with cubes.

images/cubes/table.png

True, most of the cubes have been stretched and squashed in various ways, but—cross my heart—they all started life as perfect cubes.

In fact, they all started life as a very specific kind of cube, called an axis-aligned bounding box. In this chapter, you’ll add support for them by implementing a new ray intersection algorithm, as well as the ...

Get The Ray Tracer Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.