A bound is a filter, not an object hit
A ray tracer may have many primitives to test. If a region containing several primitives is missed, every primitive inside that region can be skipped. A bounding-volume hierarchy (BVH) organizes such conservative regions into a tree. Its purpose is to avoid some expensive primitive tests; a ray hitting a box does not itself establish a hit on any primitive inside it.
Definition 6.1.1
(Ray segment and closed axis-aligned box)
A ray is , where and . We seek intersections for , with ; the upper bound may be . An axis-aligned box is the closed set , where all bounds are finite and . A ray may start inside the box, and touching a face, edge or corner counts as meeting this closed box.
Intersect three slabs
Definition 6.1.2
(Slab interval of one coordinate)
For coordinate with , the set of parameters with is the interval
The minimum and maximum handle either sign of . If , that coordinate never changes: the condition holds for no if , and for every otherwise. Do not divide by zero.
Theorem 6.1.3
(The closed-box test)
If no zero-direction coordinate rules the box out, intersect the intervals for all nonzero coordinates with . The ray segment meets the box exactly when this intersection is nonempty. Equivalently, its largest lower endpoint is at most its smallest upper endpoint.
Proof
(Coordinate conditions and one shared parameter)
The point lies in exactly when for , all at the same .
If , subtract and divide by ; the inequalities keep their direction and give . If , dividing by reverses both inequalities and gives . In both cases the solution set is , with the smaller quotient first; the minimum and maximum in the formula select it automatically. If , the condition reads , which does not depend on : it holds for all or for none.
Hence a parameter gives a point of exactly when it lies in the intersection of with every for , provided no zero-direction condition fails. If one does fail, no works and the box is missed. Finally, finitely many closed intervals have a common point exactly when : such a satisfies for all ; conversely any in lies in every interval.
Proof X-ray
Where each hypothesis does its work
The proof has one non-obvious point: the three coordinate conditions are intersected as sets of parameters, not as sets of points, because the same must satisfy all of them. That is why a ray can pass through all three slab regions in space and still miss the box: the intervals may be disjoint.
The sign of is used only once, to decide which quotient is the entry and which is the exit. Dropping the minimum and maximum would give an interval with entry greater than exit for , which would wrongly look empty. The case is separate because the quotients do not exist; there the slab condition is a yes-or-no test on . Closedness of and of the intervals is used in the last step: equality of the largest lower and smallest upper endpoint is a single common parameter, a boundary touch. With an open box this equality case would be a miss. Finite bounds and guarantee that each nonzero-direction is a genuine bounded interval.
Worked rays
Worked example 6.1.4
(Parallel coordinates)
Take and for . The first slab permits ; the other two directions are zero and their origins lie inside their slabs. The box interval is . If the second origin coordinate were instead, that parallel slab would reject the box for every .
Worked example 6.1.5
(A ray that starts inside the box)
For and , the first slab permits . Intersecting with gives : a negative entry parameter does not mean that a ray starting inside misses the box.
Worked example 6.1.6
(Mixed signs and a grazing edge)
Take and for . The -slab gives . For , , so the quotients are and , and the minimum and maximum give . The direction is zero with , so it adds no restriction. The intersection of and is , which is nonempty: the ray touches the edge at , and the closed box counts this as a hit.
Move the origin to . Now the -interval is , which is disjoint from , so the ray misses the box.
Common mistake
(Taking the lower-bound quotient as the entry for every ray)
For the quotients for the slab are and . Treating as the entry and as the exit gives , which looks empty, so the ray would be wrongly rejected. The correct interval is : the ray enters at the face and leaves at .
Common mistake
(Treating a negative entry parameter as a miss)
A ray that starts inside the box has a negative slab entry parameter, as in the second example. The test intersects with , which raises the lower endpoint to ; it does not reject the box because the entry is negative.
Counterexample mode
A box hit does not prove a primitive hit
A small triangle can lie in a corner of a large containing box. A ray passing through a different part of that box meets the box while missing the triangle. The slab test can reject that triangle only when it rejects a box guaranteed to contain it; otherwise an actual triangle test is still required.
Safe traversal and nearest hits
Definition 6.1.7
(Conservative hierarchy)
A bounding-volume hierarchy is conservative when each leaf box contains all primitives assigned to that leaf, every primitive occurs in at least one leaf, and each internal box contains the boxes of all its children.
Begin at the root, reject a node whose box interval is empty, and test primitives in surviving leaves.
Proposition 6.1.8
(Conservative pruning)
Let the hierarchy be conservative and let arithmetic be exact. (a) Rejecting a node whose box interval is empty never discards a primitive hit with parameter in . (b) If a valid primitive hit at is known, also rejecting a node whose box interval has lower endpoint strictly greater than never discards a primitive hit at a parameter .
Proof
(Ancestors contain the hit at the same parameter)
Let a primitive be hit at with , and let be any node whose subtree contains a leaf holding . By conservativeness, the leaf box contains , and each ancestor box contains the box below it, so . By the closed-box test, the box interval of is nonempty and contains ; so is not rejected in (a), and every ancestor on the path to the leaf is visited.
For (b), if , then lies in the box interval of , so its lower endpoint is at most and it is not strictly greater than . Thus is not rejected either.
Retaining equality avoids silently discarding a tied hit when a tie policy matters. Visiting a nearer box first may discover a useful bound sooner, but correctness does not rely on the visit order. For an any-hit shadow query over a finite allowed interval, one may instead stop after a valid primitive hit in that interval; that query does not require the nearest hit.
The hierarchy can be ineffective when many boxes overlap or a ray crosses most nodes, so worst-case traversal can still inspect the entire tree. The proposition assumes conservative boxes and exact comparisons. Floating-point rounding, invalid values, boundary conventions and robust primitive tests need explicit engineering; a nonconservative box can cause a false miss regardless of the tree shape.
Exercises
Quick check
(For the first worked ray, restrict to . What is the box interval?)
Intersect the two intervals.
Solution · Answer
Intersecting with gives .
Quick check
(For and with , give the interval.)
The direction is negative, so take the smaller quotient as the entry.
Solution · Answer
The first coordinate crosses at and at ; the others remain inside. The interval is .
Quick check
(A node's box interval is and a valid hit at is known. Can the node contain a closer hit?)
Compare the lower endpoint with .
Solution · Answer
No. Every point in the box on this ray has , and every descendant hit lies inside the box.
Quick check
(Why is a nonempty box interval insufficient to report a triangle hit?)
Think about how much of the box the triangle fills.
Solution · Answer
The triangle may occupy only a small part of its containing box. The ray can cross the box without meeting the triangle, so a primitive intersection test is still needed.