Creating GAS on the fly

most of the examples code built the GAS from a hardcode array. If I want to read the triangle vertices from a file and then create a GAS. Does the order of adding the triangle into the array affect the performance? Will the RT performance be the same if the orders are different? Is there an example showing how to build GAS on the fly?

Hey @EvanYL,

You can see the optixMeshViewer and optixHair SDK samples for examples of reading primitives from a file and creating the GAS on the fly. The main reason most samples hard-code their primitives is just to keep the amount of code to a bare minimum and make the OptiX API calls easier to read & understand.

The order of primitives in your build inputs does not really matter. The acceleration structure builder uses the spatial layout of primitives and not the input order in your array, so the performance will not change significantly when the input order changes.


David.

Other code examples generating GAS with triangle geometry for basic shapes (plane, cube, sphere, torus) or loading triangle mesh data from scene file formats supported by ASSIMP can be found in my OptiX examples.
Links in the sticky posts on this OptiX sub-forum.