CSCI 480/580 Lecture 13 - In-Class Problems

Two implementation details stand in the way of a fully-working bounding volume hierarchy (BVH) that uses axis-aligned bounding boxes (AABBs to accelerate ray-scene intersections. First, we need the ability to construct an axis-aligned bounding box from a given object or collection of objects. Secondly, we need to be able to intersect a ray with an AABB.

An axis-aligned bounding box can be described by its minimum and maximum extent in each dimension , , and . So we might store one in a struct such as

Our first set of tasks is to make sure we can compute an AABB for each type of object that our scenes may contain. In our raytracer, these are spheres and triangles. Since we'll be packing objects into a hierarchy of AABBs, we'll also need to know how to compute the AABB of a collection of AABBs.

  1. Write pseudocode to construct an AABB for a sphere:

  1. Write pseudocode to construct an AABB for a triangle:

  2. Write pseudocode to construct an AABB that contains a collection of AABBs. As a reminder, the type Array{AABB}, 1} signifies a 1-dimensional Array of type AABB:

At this point, we can use these primitives to construct a hierarchy of bounding boxes using the procedure described in lecture. Then all we need to do is determine whether ray hits an AABB (in which case we need to check whether it hits each of its contained objects) or misses the AABB (in which case we can prune its entire subtree!

Let's build up to the 3D case by starting simpler. The observation here is that a an axis-aligned 3D cuboid can be expressed as the intersection of three "slabs", where a "slab" is the region of space between two parallel (axis-aligned, in this case) planes.

  1. Find the range of values for which the 3D ray sits inside the "slab" between the two planes and .
  2. Repeat the prior exercise for corresponding and slabs. From here, we can observe that the ray passes through the box only if it ever sits inside all three slabs at the same time. Devise a scheme for determining whether the ray intersects the box.
  3. Give an approach for determining the coordinates of the point where the ray enters the box.

If you have time, go ahead and sketch out some pseudocode for bounding volume hierarchy construction:

  1. Given a list of objects, each of which is a Triangle or a Sphere, write pseudocode construct a bounding volume hierarchy. At each level of the tree, divide the objects in half by sorting their position (e.g., the point at their center) along a coordinate axis and create a subtree containing each half of the objects. Cycle through the , , and axes at subsequent levels of the tree.