How flat is a flat scene graph

I’m restructuring my optix scene graph code a bit and was wondering what would be the best way set it up. I’ve read a couple of times that the scene graph should be flat in order to get the most bang for the RT-core-buck, but how flat is flat?

In my current datamodel, multiple meshes can share the same transform and so ideally I would like some similar setup in OptiX where one optix Group/Transform corresponds to one datamodel transform. All transforms know their transformation in world space though, so I won’t need hierarchical transformations.

Would a setup like this be considered flat?
First level: Group node as a root
Second level: One group node pr datamodel transform. (Because transforms can only have one child)
Third level: One transform pr mesh with the mesh as its child.

From the root to the mesh there’s only one transform node, but two groups.

Alternatively I could make a scene graph with one level less
First level: Group node as a root
Second level: One transform pr mesh with the mesh as its child.

This would mean that I could have multiple optix transforms pr datamodel transform, so updating the optix transforms when the datamodel changes would be cumbersome.

Which version would work the best? Or is there an even better version that I haven’t thought of?

I’m currently on OptiX 6.5 with no immediate plans to upgrade, but thoughts and ideas related to OptiX 7 are welcome as well.

Cheers
Asger

Flat is either one or two acceleration structures on the way from scene root to leaf geometry.
A two-level AS hierarchy over triangles will run on the hardware RT cores on RTX boards.

Check the SIGGRAPH talks on OptiX here, esp. David’s “OptiX Performance Tools and Tricks” which touches BVH flattening at minute 12:20.
[url]https://devtalk.nvidia.com/default/topic/1062216/optix/optix-talks-from-siggraph-2019/post/5378948[/url]

In OptiX 7, updating OptixInstance::transform matrices doesn’t require individual host calls like in previous OptiX versions. The OptixInstance data resides on the CUDA device. That means the transforms could also be driven by a native CUDA kernel, calculating the animation of any number of instances at once.
That API is superior to the immediate mode method to set each individual transform in OptiX 6 and earlier.
I would really recommend to bite the bullet and switch to OptiX 7. I have never looked back.

Thanks Detlef.

I’ll definitely switch to OptiX 7 at some point, the benefits over OptiX 6.5 are quite nice, but the current renderer is just a means to end, in this case generating synthetic data for machine learning, so it doesn’t have to be blazingly faster or easier to debug, just not break.

Two levels means that I’ll have to go with the Group → Transform → Mesh graph and then find a way to propagate transform changes to all optix transforms. That’ll be doable.

I’ll rewatch OptiX Performance Tools and Tricks as well, might remind me of other nice tricks I’ve forgotten. ;)