Different build input types

Hello everyone,

is it possible to combine different build input types at the same time? I want to have custom primitives and triangles.

Alexander Temnyakov

Hi Alexander, welcome!

Currently you can’t mix different primitive types in a single GAS using the build inputs.

The optixAccelBuild function accepts multiple build inputs per call, but they must be all triangle inputs, all curve inputs, or all AABB inputs. Mixing build input types in a single geometry-AS is not allowed. https://raytracing-docs.nvidia.com/optix7/guide/index.html#acceleration_structures#primitive-build-inputs

We would like to relax this restriction in the future. In the mean time, you can build two GASes, one with triangles, and one with custom primitives, and add them both as instances to your IAS.


Thank you for your answer!

Could you please give me a piece of advice if I understand what I should do correctly? I have two GASes: the first with custom primitives, the second with triangles. I have a SBT. I write there data for custom primitives, then, I write data for triangles. In CUDA, I call optixTrace() twice for each ray for each GAS. In the closest hit program, I save the parameter t. Then, I choose data which I got for the ray with the lowest t. Is it correct?

Alexander Temnyakov

That approach will work, however I would recommend doing what I mentioned above, if you can. Use a 2-level hierarchy by adding your 2 GAS BVH as instances into a top-level IAS BVH. Then you only need to trace a single ray.

A good example of this approach can be seen in the optix SDK sample called optixHair, which has triangle primitives in one GAS, curve primitives in another GAS, and they are combined using OptiX instancing and two-level traversal. You can do the same, and simply replace the curve primitives with your custom primitives. Pay attention to the various build flags and pipeline flags, you will need to use either OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_SINGLE_LEVEL_INSTANCING or OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_ANY, depending on what other features you would like to support.

You can see the comments in optix_7_types.h or the Programming Guide for more information about instancing. https://raytracing-docs.nvidia.com/optix7/guide/index.html#acceleration_structures#instance-build-inputs