Putting It Together
Your ray tracer now supports spheres, planes, and cubes. How awesome is that? By all means, experiment and see what you can make by combining the three primitives, but first: what can you make using only cubes?
Try it out. Form a room out of a large cube. Make a table out of five cubes: four for the legs, and one for the table’s surface. Put a box on the table. Scatter some boxes on the floor.
Here’s another challenge: using only two cubes, can you make a room whose floor and ceiling have a different texture than the walls?
You can also make these algorithms faster. For example, when comparing a ray with the cube’s sides, the algorithm insists on checking all six planes, even if it’s clear by the first or second comparison ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access