Bounding Volume Hierarchy construction and upload.
More...
#include <vector>
#include <cstddef>
#include <GL/glew.h>
#include <glm/glm.hpp>
#include "mesh.hpp"
Go to the source code of this file.
|
| struct | BVHNode |
| | A single node of the BVH, structured following the std430. More...
|
|
| bool | buildBVH (vector< GPUTriangle > &triangles, vector< BVHNode > &bvh_nodes) |
| | Builds the BVH using a triangle list. Recursively splits each triangle node at median along the longest axis of its AABB, reorders triangles in place so each leaf references a range. The resulting array is written to bvh_noes with root at index 0.
|
| bool | uploadBVH (const vector< BVHNode > &bvh_nodes, GLuint &ssbo) |
| | Uploads the BVH node array to GPU SSBO. Creates the buffer on first use and fills it with bvh_nodes. The shader reads this buffer starting from the root idx 0.
|
|
| const float | AABB_EPS = 1e-4f |
| | Smap epsilon used to pad AABBs and avoid near-zero thickness.
|
Bounding Volume Hierarchy construction and upload.
- Author
- Leonel Matos
- Date
- 2026-04-02
- Copyright
- Copyright (c) 2026 Builds a BVH over the scene triangles (through median split on the longest axis of each node) and uploads the flattened node array to SSBO
◆ buildBVH()
Builds the BVH using a triangle list. Recursively splits each triangle node at median along the longest axis of its AABB, reorders triangles in place so each leaf references a range. The resulting array is written to bvh_noes with root at index 0.
- Parameters
-
| triangles | In-out triangle buffer |
| bvh_nodes | Output flattened node array |
- Returns
- true on success
◆ uploadBVH()
| bool uploadBVH |
( |
const vector< BVHNode > & | bvh_nodes, |
|
|
GLuint & | ssbo ) |
Uploads the BVH node array to GPU SSBO. Creates the buffer on first use and fills it with bvh_nodes. The shader reads this buffer starting from the root idx 0.
- Parameters
-
| bvh_nodes | The node array produced by buildBVH |
| ssbo | In-out SSBO handle, created if zero |
- Returns
- true on success
- See also
- buildBVH
◆ AABB_EPS
| const float AABB_EPS = 1e-4f |
Smap epsilon used to pad AABBs and avoid near-zero thickness.