Example of dynamic BVH building and BVH update?

Is there a simple OptiX example with dynamic BVH update and build?

For example, I want to generate some mesh geometry on the fly (bottom level BVH)
and then just update the top level BVH. Or would the top level BVH be rebuild from scratch?

Please search the OptiX SDK 7.4.0 sources for the enum OPTIX_BUILD_OPERATION_UPDATE.
That is used in optixAccelBuild() calls which only update (refit) data inside acceleration structures (AS) while maintaining the topology.
This requires that the AS buildFlags contain the flag OPTIX_BUILD_FLAG_ALLOW_UPDATE.

There are at least three examples using that inside the OptiX SDK (optixDynamicGeometry, optixMotionGeometry, optixVolumeViewer).
I’m using it in the intro_motion_blur example to update the root IAS after changing the motion transforms:

Mind that when changing a geometry AS and the axis aligned bounding box (AABB) around that changes or when changing the transform in instances or explicit transforms (e.g. for motion blur), then you need to update all instance AS in the hierarchy above that as well to be able to hit all geometry.

Please also read the performance advices inside this OptiX Programming Guide chapter:

Thanks for your reply. I will use the resources you mentioned.

It’s true, as the docs say, that building an acceleration structure can be computationally costly. But you might be amazed, as I am, at how fast it actually happens in practice. This is one GAS with 16k spheres being rebuilt every tick. I’m still getting over 50 fps and that includes time spent in the denoiser on my antique GeForce RTX 2070 Super. :)

1 Like