Sample for Optix Instancing


I have successfully added Optix and normal rendering is working fine even with very complicated objects and light settings. I wanted to add Instancing support now but I am not able to find any samples or examples for it.
Can some one please point to any reference sample or give example of instancing usage here?

Some questions :
Lets say I have two mesh in my scene.
Square and Sphere. Out if this Sphere has two instances.
Currently , I am just creating one GAS and putting geometry even for instances. So sphere geometry will be duplicated.

Now all research I did on instancing I think I need to create one GAS for Square (lets call it GAS1) then one for sphere geometry (lets call it GAS2).
One more GAS for instance and in structure of OptixInstance I pass traversable handle of GAS2.

The unclear part starts here,
I have three GAS handles.

  1. How will Optix recognize all this three handles to use ? ( should I just put them in Launch Params when calling OptixLaunch) ?

It would be great if some one can tell me my observations on creation of instancing are right and if yes then how to set up these multiple AS.


Hey @parkul24,

You can find an example of instancing in the optixDynamicGeometry SDK sample. Look for the section with the comment "// Update the IAS" in the function updateMeshAccel(). Some other samples that make use of instancing are: optixHair, optixVolumeViewer, optixSimpleMotionBlur, and optixMotionGeometry.

Conceptually, the answer to your question is that you need what’s called an Instance Acceleration Struction, or IAS, that will contain the three GAS handles. Then you put the single handle to the IAS in your launch params, and use that in your call to optixTrace(). OptiX will take care of traversing all the instances.

Pay attention to your OptixTraversableGraphFlags in your pipeline compile options, and also check out the “instance build inputs” section of the programming guide:


1 Like