Problem with Motion Blur

Howdy,

Thanks for 5.0 … looks like a great update!

I’m trying to add motion blur to a physics simulation project. I’m using key type RT_MOTIONKEYTYPE_SRT_FLOAT16 applied to Transform nodes. The border modes, motion range and motion steps are default values. The 1st key is set to the previous transform from the physics engine and the 2nd key is set to the physics engine’s current transform. I’m pretty sure that the math is right in the keys since the motion blur itself looks correct when the objects are moving.

The problem I have is that when an object stops moving, Optix is still displaying motion blur, even though the 1st and 2nd keys differ only by slight round off errors. If I reset the simulation so that the 1st and 2nd keys are the same again, there’s no motion blur from Optix as expected.

In the video, I’m toggling MB on/off by changing the number of steps from 1-2 in the gui.
https://youtu.be/OwE98Zx3WhE

I suspect this is user error but I’ve tried everything thing I can think of and can’t fix it. Any idea what might be causing this?

How slightly is ‘slightly’? Very small perturbances of an SRT matrix can have large effects.

Thanks for the response.

Here’s the debug output while the cow is resting on the ground. But I don’t think it’s the problem

39.207670	DEBUG [IOptixEngine.cpp:169 IOptixEngine::srt_previous() t8592]	"-----------TICK"
39.207761	DEBUG [MathUtil.h:49 wabi::matStr4f() t8592]	"Prevous transform matrix"
39.207939	DEBUG [MathUtil.h:44 wabi::vecStr4f() t8592]	"(0.965754, 0.232610, -0.114944, -0.016212)"
39.208041	DEBUG [MathUtil.h:44 wabi::vecStr4f() t8592]	"(0.185621, -0.928948, -0.320315, 0.493873)"
39.208138	DEBUG [MathUtil.h:44 wabi::vecStr4f() t8592]	"(-0.181285, 0.288009, -0.940312, 1.374789)"
39.208238	DEBUG [MathUtil.h:44 wabi::vecStr4f() t8592]	"(0.000000, 0.000000, 0.000000, 1.000000)"
39.208280	DEBUG [MathUtil.h:49 wabi::matStr4f() t8592]	"Current transform matrix"
39.209551	DEBUG [MathUtil.h:44 wabi::vecStr4f() t8592]	"(0.966069, 0.231030, -0.115481, -0.015370)"
39.209660	DEBUG [MathUtil.h:44 wabi::vecStr4f() t8592]	"(0.183601, -0.928737, -0.322083, 0.493927)"
39.209758	DEBUG [MathUtil.h:44 wabi::vecStr4f() t8592]	"(-0.181663, 0.289952, -0.939642, 1.373754)"
39.209855	DEBUG [MathUtil.h:44 wabi::vecStr4f() t8592]	"(0.000000, 0.000000, 0.000000, 1.000000)"

I tried another render where I set the previous and current transforms equal after enough frames had passed so that the cow was motionless … and I’m still seeing the blur on the cow while it’s resting

So even when you provide the exact same SRT description for both transforms you are seeing the motion blur? If so we should get a reproducer from you so we can debug on our end. Please email optix-help@nvidia.com and I can help you investigate further.

Thanks

So even when you provide the exact same SRT description for both transforms you are seeing the motion blur?

I was not able to reproduce this behavior using the optixMotionBlur sample with the following command lines, all of which should set up two keys with transforms that are close to identity:

./bin/optixMotionBlur -t srt --rotate 0 0 1 0
./bin/optixMotionBlur -t srt --rotate 0 0 1 1
./bin/optixMotionBlur -t srt --translate 0.00001 0.0001 0

I get an image of the cow with all these that is either not blurred or very slightly blurred, as expected. I also tried setting a non-identity transform for both keys, by modifying the sample code.

Another question: your debug output above is a combined 4x4 matrix. Are you converting back and forth between this and SRT format? Could you print the SRT elements separately, e.g., the 4-element quaternion R, the scale/shear S, and the translation T.

Sorry I haven’t had time to dig deeper into this.

Here’s the SRT elements and pivot separately. Once the cow comes to rest they’re exactly the same for the both transforms on each frame

IOptixEngine::srt_previous() t18076]	"------------------- frame 615"
IOptixEngine::srt_previous() t18076]	"Quaternion1: 0.169321, 0.245473, 0.662466, 0.687178"
IOptixEngine::srt_previous() t18076]	"Translation1: 0.872862, 0.15359, 0.518423"
IOptixEngine::srt_previous() t18076]	"Scale1: 1, 1, 1"
IOptixEngine::srt_previous() t18076]	"Pivot1: 0, 0, 0"
IOptixEngine::computeMotionBlur() t18076]	"Quaternion2: 0.169321, 0.245473, 0.662466, 0.687178"
IOptixEngine::computeMotionBlur() t18076]	"Translation2: 0.872862, 0.15359, 0.518423"
IOptixEngine::computeMotionBlur() t18076]	"Scale2: 1, 1, 1"
IOptixEngine::computeMotionBlur() t18076]	"Pivot2: 0, 0, 0"

Here’s the code I’m using to create the motion blur at each frame. I use Eigen C++ for math. Maybe that’s where the problem is

https://gist.github.com/Hurleyworks/3f3c060b41b8e2f5cb0530b14a3d6107

Thanks for the help

Do you still see blur with identical values as shown in the listing above?

If you want to email me (username @ nvidia) then I can follow up with some instructions for capturing more debug info as your program runs, so I can inspect values.

Found it! It was my bug. While debugging I could see that the previous rotations and current rotations were exactly the same when the cow had come to rest as expected. But the rotation values coming out of lerp_srt_to_key() were totally different.

The problem was that after obtaining the rotation axis and angle from my math library, I created the rotation values from the Optix Quaternion components.

Quaternion q(make_float3(axis.x(), axis.y(), axis.z()), angle);
float4 rotation = make_float4(q.m_q.x, q.m_q.y, q.m_q.z, q.m_q.w);

and passed that rotation to lerp_srt_to_key();

Inside lerp_srt_to_key(), the Quaternion constructor was expecting the axis/angle format. Once I changed the passed in rotation to angle/axis format it works as expected.

//Quaternion q(make_float3(axis.x(), axis.y(), axis.z()), angle);
// float4 rotation = make_float4(q.m_q.x, q.m_q.y, q.m_q.z, q.m_q.w);
float4 rotation = make_float4(axis.x(), axis.x(), axis.x(), angle);

Thanks for taking the time to help. Sorry for wasting your time!