I'm new to computer graphics programming so I apologize in advance if my question is stupid.

I'm trying to implement a BVH for my ray tracer and I looked at some lectures explaining BVH. They all mention that a BVH takes in primitives which are then divided until they end up as nodes of the tree, but when I looked at scratch-pixel, they were talking about having the meshes as nodes. I'm a bit confused here because I'm not sure exactly which is the right way of doing it. Should the nodes contain the meshes as a whole or should I just feed the BVH construction algorithm the primitive triangles (ignoring the fact that they are a part of a mesh by just grouping them into a list/array of primitives)?

  • $\begingroup$ RE "talking about having the meshes as nodes." that seems very unlikely unless each mesh is trivial, say, only a few triangles. Testing rays against triangles is much more expensive than against an AABB or sphere and, since most rays will typically miss all but a handful of triangles, in a given mesh, it would be quite inefficient. $\endgroup$
    – Simon F
    Commented May 14, 2020 at 14:52
  • $\begingroup$ I would go with a target of a handful of triangles, say 6-8 triangles per BVH node. There will be duplicate triangles though if you hit a leaf node and didn't hit any triangles and then move to a neighbouring node, the same triangle can exist in both nodes (The number of shared triangles typically increases the less triangles per node you opted for) $\endgroup$
    – PaulHK
    Commented May 19, 2020 at 6:06

1 Answer 1


Bounding Volumes

A bounding volume is for example an Axis-Aligned Bounding-Box (AABB), a generaal Bounding-Box not aligned with the major axes or a Bounding-Sphere. They differ in

  • how much memory they take (e.g. a sphere takes only 4 floats, AABB 6 floats)
  • how good they enclose the object's geometry
  • how fast are the related computations (mainly intersection tests).

You will find an extensive overview at Wikipedia.

Hierarchy of volumes

So in the hierarchy of bounding volumes, instead of whole meshes you will store only their bounding volumes. You choose a single type, e.g. a bounding sphere, and will use it to build the whole BVH. At the bottom level each bounding volume will probably enclose only a single object. You will build the hierarchy up by enclosing pairs or smaller groups of volumes in a larger volume.

So using spheres you would enclose each object into a bounding sphere at first. Then at the higher levels of the hierarchy, you would always create a new sphere enclosing a few spheres from the previous level which are close to each other. You proceed until a single root sphere encloses all 3D objects in your scene.

There are different strategies to create BVH. But all have in common that complex structures like triangle meshes are hierarchically clustered using very simple entities.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.