Optix: Rendering time-variant data
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.