Chapter 16Constructive Solid Geometry (CSG)

You’ve made it through matrix transformations, Phong illumination, reflection, refraction, and ray-object intersections for a variety of primitive shapes. For this last feature, you’ll implement constructive solid geometry, or CSG—a method of combining those primitives via set operations. This lets you create much more complex shapes, like these:

images/csg/csg-demo.png

It’s true that any of those shapes could have been assembled in a 3D modeling app and then exported to an OBJ file, which you could have imported and rendered. Using CSG is better in this case for two significant reasons:

  1. To get per-triangle coloring to work, ...

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.