<h1>Bounding Volumes</h1>
<p>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</p>
<ul>
<li>how much memory they take (e.g. a sphere takes only 4 floats, AABB 6 floats)</li>
<li>how good they enclose the object's geometry</li>
<li>how fast are the related computations (mainly intersection tests).</li>
</ul>
<p>You will find an extensive overview at <a href="https://en.wikipedia.org/wiki/Bounding_volume" rel="nofollow noreferrer">Wikipedia</a>.</p>
<h1>Hierarchy of volumes</h1>
<p>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.</p>
<p>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.</p>
<p>There are different <a href="https://en.wikipedia.org/wiki/Bounding_volume_hierarchy" rel="nofollow noreferrer">strategies to create BVH</a>. But all have in common that complex structures like triangle meshes are hierarchically clustered using very simple entities.</p>

CC BY-SA 4.0
2020-05-13T23:51:57.830Z
2020-05-14T17:06:13.387Z
2020-06-18T08:32:12.800Z
Isolin
<p>I'm new to computer graphics programming so I apologize in advance if my question is stupid.</p>

<p>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)?</p>

CC BY-SA 4.0
2020-05-14T14:52:42.977Z
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.
Simon F
CC BY-SA 4.0
2020-05-19T06:06:45.163Z
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)
PaulHK
<raytracing><rendering><optimisation><bounding-volume-hierarchy><optimization>
Ray Tracing Bounding Volume Hierarchies nodes
Sam
# Ray Tracing Bounding Volume Hierarchies nodes

(Asked by: username_0 on 2020-05-13)

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)?

**Tags:** raytracing, rendering, optimisation, bounding-volume-hierarchy, optimization

> **Comments:**
> **username_1**: 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.  
> **username_2**: 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)  

---

## 1 answers

### Answer by username_3 on 2020-05-13. Score: 1 | Accepted answer

# 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](https://en.wikipedia.org/wiki/Bounding_volume).

# 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](https://en.wikipedia.org/wiki/Bounding_volume_hierarchy). But all have in common that complex structures like triangle meshes are hierarchically clustered using very simple entities.


---

