Motion blur crashes on multiple transforms

I know your gonna tell me to update Optix, but I’ve stucked with 6.5 for now and need to add a motion blur.

I am facing a problem when applying motion keys to both the root of the hierarchy and nodes with geometries. It works in these wierd scenarios:

  1. I can add motion blur to root transform and two objects. Adding a 3rd object crashes the app.

  2. I can add motion blur to multiple objects, if root has no motion blur

applying Motion blur looks like this:

Quaternion q1x(make_float3(1, 0, 0), AI_RAD_TO_DEG(rotation.x));
Quaternion q1y(make_float3(0, 1, 0), AI_RAD_TO_DEG(rotation.y));
Quaternion q1z(make_float3(0, 0, 1), AI_RAD_TO_DEG(rotation.z));

Quaternion q2x(make_float3(1, 0, 0), AI_RAD_TO_DEG(rotation.x) + t0.Rx);	
Quaternion q2y(make_float3(0, 1, 0), AI_RAD_TO_DEG(rotation.y) + t0.Ry);	
Quaternion q2z(make_float3(0, 0, 1), AI_RAD_TO_DEG(rotation.z) + t0.Rz);	

float3 pos0 = make_float3(position.y, position.z, position.x);
float3 pos1 = make_float3(position.y + t0.Tx, position.z + t0.Ty, position.x + t0.Tz);

lerp_srt_to_key(keys,  scale, q1y * q1z * q1x, make_float3(t0.Px, t0.Py, t0.Pz), pos0, 1.0f);
lerp_srt_to_key(keys+16, scale, q2y * q2z * q2x, make_float3(t0.Px, t0.Py, t0.Pz), pos1, 1.0f);
  
transform->setMotionRange(0.0f,1.0f);
transform->setMotionBorderMode(RTmotionbordermode::RT_MOTIONBORDERMODE_VANISH, RTmotionbordermode::RT_MOTIONBORDERMODE_VANISH);
transform->setMotionKeys(2, RTmotionkeytype::RT_MOTIONKEYTYPE_SRT_FLOAT16, keys);

and for the root:

Quaternion qy1(make_float3(0, 1, 0), renderer->parameters.modelRotation.y - halfAngle);
Quaternion qx1(make_float3(1, 0, 0), renderer->parameters.worldRotation.x);
Quaternion qz1(make_float3(0, 0, 1), renderer->parameters.worldRotation.z);

Quaternion qy2(make_float3(0, 1, 0), renderer->parameters.worldRotation.y + halfAngle);
Quaternion qx2(make_float3(1, 0, 0), renderer->parameters.worldRotation.x);
Quaternion qz2(make_float3(0, 0, 1), renderer->parameters.worldRotation.z);

lerp_srt_to_key(keys, make_float3(1, 1, 1), qy1 * qz1 * qx1, make_float3(0, 0, 0), -renderer->parameters.worldMove * 0.5f, 1.0f);
lerp_srt_to_key(keys+16, make_float3(1, 1, 1), qy2 * qz2 * qx2 , make_float3(0, 0, 0), renderer->parameters.worldMove * 0.5f, 1.0f);

		
transformation->setMotionRange(0, 1.0f);
transformation->setMotionBorderMode(RTmotionbordermode::RT_MOTIONBORDERMODE_VANISH, RTmotionbordermode::RT_MOTIONBORDERMODE_VANISH);
transformation->setMotionKeys(2, RTmotionkeytype::RT_MOTIONKEYTYPE_SRT_FLOAT16, keys);

What i get is:
Unknown error (Details: Function “_rtContextLaunch2D” caught exception: Encountered a CUDA error: cudaDriver().CuEventSynchronize( m_event ) returned (700): Illegal address, file: , line: 0)

thrown on context→launch.

I would appreciate either dubugging hints or simply explanation what am I doing wrong…

RTX 3060, i5-12400F, 32GB.

Hi @szamil,

We used to have lots of people using many motion blurred objects, so we know there’s nothing inherently wrong with that idea, and it’s known to work. I can’t see anything wrong from the code snippets you shared. Since you’re doing pointer math there, are the keys buffers big enough and pointing at the right place, and is the hard-coded offset correct with absolute certainty? Is there any mixing of host and device pointers? That would be the first set of things to triple-check. You can also over-allocate your keys, and remove any offsets, to verify whether you can avoid the crash (even if the keys or other data is temporarily incorrect.) Assuming we can test it, do you have a minimal complete working reproducer you can share?

You’re right I’m very tempted to recommend updating to a newer OptiX, but I totally understand the desire to get something working and not get sidetracked refactoring or rewriting. I do want to point out that aside from our recommendations to upgrade, OptiX 6.5 and earlier have been officially deprecated and support is going to be removed from the driver in the future, as mentioned in the OptiX 9.0 release notes. Are you able to stay on your current driver for the remaining lifetime of your project? Hopefully this is for a project that is not distributed to others, or the audience is all okay with using an old version-locked driver?

If you would like some help upgrading from OptiX 6.5 to a newer version, we could discuss that.


David.

Thank you David!

Yes, I’m going to upgrade to 9.0. I think I’ll need to start with new samples, or would you suggest a different approach? What would be the most difficult “porting” part?

Back to my problem:
How could I debug such a problem? I think I have an out-of-bounds problem that occurs while traversing the meshes. So the crash happens even if my hit program is empty.

Appreciate any reply!

One of the main hurdles when upgrading OptiX from 6.5 is to understand and use the Shader Binding Table (SBT). It’s not difficult, but it might take a minute to understand and get comfortable with. It’s just a lookup table, but you’ll want to review the Programming Guide and a couple of our SDK samples to see it in action. There’s no explicit scene graph anymore, BVH builds are more explicit, instancing and transforms look slightly different, there are no selector nodes, and the syntax for setting up shaders is a little different. Those things are easy to learn. OptiX prior to version 7.0 was a slightly higher level API, and version 7 and up are a lower level API that’s much closer to what DirectX and Vulkan ray tracing APIs look like (so if you know either of those, it’ll help). Aside from that, there’s a little getting used to using CUDA for your memory allocation and stream management and other things. That’s also easy and most people seem to prefer it. Allow yourself plenty of time; there’s nothing too hard when porting, but there are lots of little details.

For debugging this, I’m not sure, but maybe try increasing the size of your buffers and zero-initializing them, to see if the illegal address error goes away. Does it all work with the motion blur disabled? Does it work if you use more than 2 keys?

Which driver and OS are you using? If you’re on a current driver, it might be worth trying to find and check an old driver close to when OptiX 6.5 was release. The driver number at the time was a 435.


David.