1 of 4

Your RightSignal

Learn1 / 3

Bounding volume hierarchies

The concept

How a ray-traced game tests millions of triangles for each light ray

Ray tracing draws a frame by firing rays from the camera into a scene. Each ray must find the first triangle it hits. A game scene can hold millions of triangles, so testing every ray against every triangle is far too slow for real time.

A bounding volume hierarchy (BVH) wraps small groups of triangles in boxes, then those boxes in bigger boxes, up to one box around the whole scene. The result is a tree with the triangles in its leaves.

A ray tests the top box, then only the child boxes it passes through. A missed box skips everything inside. A ray aimed at the sky misses the boxes around a car, a tree and a house, so it tests none of their triangles.

What it’s forEstimates how many levels of boxes a ray goes through in a balanced binary BVH.

depth ≈ log₂(n)

n
number of triangles in the scene, e.g. 1,000,000
log₂
how many times you can halve n before reaching 1
depth
levels from the top box down to a single triangle

What it givesA ray checks a few boxes per level instead of testing every triangle.

  1. n = 1,024 triangles → log₂(1,024) = 10 levels
  2. n ≈ 1,000,000 → about 20 levels, since 2²⁰ = 1,048,576
  3. So a single path down is about 20 box tests, not a million triangle tests