move objects

Hello developers,

I am working with optiX 9.0. I am building an application for calculating raidative transfer in 3-D models.

I want to move a CAD model in my application. Right now I am just updating the transformation matrix and calling createGeometry() function in every iteration. This technique works perfectly but the only problem is the speed.
creating geometry again in every iteration is a quite expensive task. can any one suggest me any good technique to perform this task.

If you’re using OptiX 3.9.0 right now, I would recommend to upgrade to OptiX 3.9.1 which is more robust and faster and supports Pascal.

You should explain what functionality your createGeometry() function implements exactly.

  • Are you using OptiX Transform nodes inside the OptiX scene hierarchy?
  • Or are you pre-transforming the attributes inside buffers attached to in OptiX Geometry node every frame?
  • Or does createGeometry() imply you’re actually replacing the OptiX Geometry nodes?

The first case would give you the best performance when animating with transforms (4x4 matrices), though scene traversal and therefore rendering performance can be slower due to the additional hierarchy level(s).
Updating the Transforms is comparably fast, because the accelerations structure topology will not change and the BVH can be rebuilt simply by refitting.
Read the OptiX Programming Guide about the acceleration structure property “refit” and “refine”.
Debug through the OptiX SDK example “swimmingShark” and look for the code doing “setMatrix”.
A rather old but still applicable presentation on these topics can be found here:
http://on-demand.gputechconf.com/gtc/2013/presentations/S3475-Ray-Tracking-With-OptiX.pdf

In the second case, if you’re updating the Geometry attributes per frame that will require a rebuild of the acceleration structures. The performance of that depends on the acceleration structure builder you choose, e.g. Trbvh builds faster than Bvh, which builds faster than Sbvh.
This should only be necessary for applications where the geometry content actually changes, like when dynamically generating surfaces from simulation data etc.

In the third case, if you’re actually recreating the Geometry nodes just because the attribute data changes, then don’t do that.

Thank you for your response. I am actually updating my Transform matrix, removing the child, and then adding new child and thn updating the geometry group.

geometrygroup->removeChild(4);
				InsertModel("C:/ProgramData/NVIDIA Corporation/OptiX SDK 3.9.0/SDK/tutorial/glasses_grid.obj", geometrygroup, box_matl, mesh_intersect, m0, false); //C:/ProgramData/NVIDIA Corporation/OptiX SDK 3.8.0/SDK/tutorial
				m_context["top_object"]->set(geometrygroup);

And one more important thing is that my CAD model contains almost million of vertices. Is this a reason?

Why do you need to remove the child number 4, add a new child, and update the geometry group when your question is how to “move objects”?

Your three lines code snippet doesn’t give enough background either. That’s loading a hard-coded OBJ file from disk. That would always be the exact same geometry and a complete waste of time when done for each animation step, unless you’ve overwritten it during your animation.

You said you update a Transform node. Do you only want to move objects with affine transformations or does your animation also involve changing geometry attributes every time?

In either case my previous answer contains all necessary details to investigate other methods on your side.

Thank you so much. yes your previous reply contains all the necessary details.
I went through simpleAnimation and swimming sharks SDK. it really solved my problem.
Thank you.

I know this is an old Topic. But I am wondering what is the best practice to move an primitive with Prime without rebuilding the whole scene.

Right now I use:

Model scene = context->createModel();
scene->setInstances(numInstances, RTP_BUFFER_TYPE_HOST, &instances[0], RTP_BUFFER_FORMAT_TRANSFORM_FLOAT4x3, RTP_BUFFER_TYPE_HOST, &transforms[0]);

to create the scene. And whenever I want to move a primitive, I simply change my transform object and call again:

scene->setInstances(numInstances, RTP_BUFFER_TYPE_HOST, &instances[0], RTP_BUFFER_FORMAT_TRANSFORM_FLOAT4x3, RTP_BUFFER_TYPE_HOST, &transforms[0]);

I hardly doubt that this is the best way to do this, since, I suppose, it means to rebuild the whole scene and recreating the accelartion structure every time the primitive moves.