Optix: Rendering time-variant data I have a Optix Raycasting renderer which loads and renders VTK files.
For a single static model this works fine.

But now my dataset consists of multiple timesteps which I want to display in a animated fashion.

Each couple of frames or seconds the displayed model has to be switched out with the next one.
If possible I want to refrain from rebuilding the acceleration structure each time this happens.

So my question: Can I just load all models at once, place them in the global acceleration structure and then just switch all off except the one currently displayed.
My hope is that this would be more efficient.

Edit 1:
I have now build a variant in which I create optix::Acceleration and optix::Group for each of the timesteps separate and each time the active timestep changes I just 

_context["top_object"]-&gt;set(mesh_group[timestep]);


But each this call takes nearly half a second. I think optix does quite some work in the background when I switch this object out.
This delay is not acceptable for me as it makes the playback of my "animation" stutter.

Has anyone a idea how to do this more efficient?
With help from the Nvidia Forum and two very helpful and friendly Nvidia employees I found the perfect solution.

In OptiX there is a so called selector node. This is a special scene-graph node that utilizes a user specified program to select which child a ray should traverse and which not.

#include &lt;optix.h&gt;

rtDeclareVariable(unsigned int, timestep, , );

RT_PROGRAM void animation_selector()
{
    rtIntersectChild(timestep);
}


This is a simple version of such a selection program. From the CPP-API side the current timestep will be set and can be used to make the animation. And then when the scene graph is traversed the program just says "Traverse only the child with index 'timestep'". This does not trigger a recompile or refit and therefore is nearly instant.

The selector node is simply created in following way:

optix::Selector selector = context_-&gt;createSelector();

std::string path_to_ptx = VRTPtxFinder::GetPtxPath("VistaRayTracing_generated_animation_selector.cu.ptx");

optix::Program selection_program = context_-&gt;createProgramFromPTXFile(path_to_ptx, "animation_selector");
selector["timestep"]-&gt;setUint(0u);
selector-&gt;setVisitProgram(selection_program);

for(auto group : groups)
{
  selector-&gt;addChild(group);
}


The only cost is one additional method call for each traversal and thereby also a slightly bigger stack which caused me some problems with a stack overflow so when using this, keep an eye on the stack size.