Traverse a BVH from a specific node

Hi there,

Is it possible to traverse a BVH from a specific node (of the BVH) rather than from the root every time? This might be helpful for continuous ray tracing in a large scene. I understand that it is not allowed to access the BVH data directly. Thanks.

Sway

1 Like

Yes, in principle that is possible but could get rather complicated.

optixTrace takes a traversable handle as first argument which is the root of that ray’s traversal through the acceleration structure.
Means if you know the traversable handle of the specific node in your scene’s AS hierarchy you want to start traversal from, you can use that as argument to optixTrace instead.

Now the issues with that:
That traversable root handle defines your “world”!

Obviously only the AS nodes beneath that new traversable root node will be reachable.

That also defines your world coordinate space because that is always defined by the transform list above the hit leaf geometric primitive.
Means your full scene root node (usually an instance AS with transforms on the instances) and your specific node inside that, most likely have different world coordinate spaces for that ray. (E.g., GAS have no transform which means then world space is the GAS’ object space which is the identity transform.)

If you want to keep working inside the same global scene world space, you would need to be able to transform your hit results into that when starting traversal at a different AS traversable handle.
How involved that becomes, depends on how your scene hierarchy is structured. Think of instances using the same geometry AS multiple times. Add motion transforms into the mix and things get involved.

When only GAS can be your new root for a specific traversal, you would need the respective concatenated transformation matrix and its inverse for the unique path through the scene hierarchy when originally reaching that GAS. That would be the simple case when that can be calculated at runtime from a previous hit.
If you want to store these upfront, you would need to be able to calculate these two matrices for each unique path through the AS hierarchy and be able to identify that path per GAS to index into those.

If any higher IAS should become the new root of a traversal, things get more involved. You would need to be able to concatenate only the unique transform list above that and apply it to the remaining transform list until the leaf geometric primitives.

When only using two-level AS hierarchies (IAS → GAS) I wouldn’t start thinking about it, because that case is fully hardware accelerated by the RT cores on RTX GPUs.
If you’re using more complex AS hierarchies, things can get complicated as described above.
It also depends on how you’re assigning data to the geometric primitives. In my examples, materials are assigned at instance level, which would break when not starting the traversal at that instance AS.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.