Multiplication between two slerped quaternion

 Posts: 75
 Joined: Sun Aug 19, 2012 3:24 pm
 Contact:
Multiplication between two slerped quaternion
Hi, I want to implement motion blur with scene hierarchy.
As far as I know, the simple way to achieve motion blur is doing rayobject intersection in the object space.
First transform a ray into the object space using a transformation matrix sampled at the time t, then do the intersection test and transform back into the world space.
The problem is that I have scene hierarchy, where it is possible to have nested animated transforms.
Let me think 2 pairs of transforms.
Animated transform 1: M1(at t = t_s), M2 (at t = t_e)
Animated transform 2: M3(at t = t_s), M4 (at t = t_e)
t_s <= t < t_e
It seems that Slerp(M1, M2, t) * Slerp(M3, M4, t) is not equal to Slerp(M1M3, M2M4, t).
Therefore, the correct way appears that calculating Slerp multiple times, but it clearly seems to be heavy.
Are there any good way to achieve nested motion blur?
Thanks
As far as I know, the simple way to achieve motion blur is doing rayobject intersection in the object space.
First transform a ray into the object space using a transformation matrix sampled at the time t, then do the intersection test and transform back into the world space.
The problem is that I have scene hierarchy, where it is possible to have nested animated transforms.
Let me think 2 pairs of transforms.
Animated transform 1: M1(at t = t_s), M2 (at t = t_e)
Animated transform 2: M3(at t = t_s), M4 (at t = t_e)
t_s <= t < t_e
It seems that Slerp(M1, M2, t) * Slerp(M3, M4, t) is not equal to Slerp(M1M3, M2M4, t).
Therefore, the correct way appears that calculating Slerp multiple times, but it clearly seems to be heavy.
Are there any good way to achieve nested motion blur?
Thanks

 Posts: 83
 Joined: Thu Apr 24, 2014 2:27 am
Re: Multiplication between two slerped quaternion
I believe that when you want to render a complex scene, everything should be "flat"
so convert your hierarchy scene as a preprocess to a flat scene "this would take a fraction of a second"
so convert your hierarchy scene as a preprocess to a flat scene "this would take a fraction of a second"

 Posts: 75
 Joined: Sun Aug 19, 2012 3:24 pm
 Contact:
Re: Multiplication between two slerped quaternion
As you say I firstly convert the hierarchy to a flat object list.MohamedSakr wrote:everything should be "flat"
What I want to know is whether it is possible to convert hierarchical animated transforms to one animated transform or not.

 Posts: 83
 Joined: Thu Apr 24, 2014 2:27 am
Re: Multiplication between two slerped quaternion
let's consider both cases and check which one is true :shocker_0x15 wrote: It seems that Slerp(M1, M2, t) * Slerp(M3, M4, t) is not equal to Slerp(M1M3, M2M4, t).
a) Slerp(M1, M2, t) * Slerp(M3, M4, t)
M = (t * M1 + (1  t) * M2) * (t * M3 + (1  t) * M4); //this looks wrong, as M will be proportional to t^N, where N is the object depth in hierarchy.
b) Slerp(M1M3, M2M4, t)
M = t * M1M3 + (1  t) * M2M4; //this looks correct, as the term M1M3 represents the global transform at time t = t1, and M2M4 represents the local transform a time t = t2
from (a) and (b) , they are not equal., (b) is the correct approach.
so easiest and most robust solution, store t1 and t2 global transform in the object class, like this you won't calculate it when doing motion blur "just 1 Slerp calculation"

 Posts: 75
 Joined: Sun Aug 19, 2012 3:24 pm
 Contact:
Re: Multiplication between two slerped quaternion
Is your notation:
(t  1) * A + t * B
implicitly meaning spherical linear interpolation? if you mean simple linear interpolation, it is wrong.
I know that
Slerp(M1, M2, t) * Slerp(M3, M4, t)
is the obviously correct calculation and the result from this is what I want. However, this require two slerp calculations.
Unfortunately
Slerp(M1M3, M2M4, t) is not equal to Slerp(M1, M2, t) * Slerp(M3, M4, t).
(t  1) * A + t * B
implicitly meaning spherical linear interpolation? if you mean simple linear interpolation, it is wrong.
I know that
Slerp(M1, M2, t) * Slerp(M3, M4, t)
is the obviously correct calculation and the result from this is what I want. However, this require two slerp calculations.
Unfortunately
Slerp(M1M3, M2M4, t) is not equal to Slerp(M1, M2, t) * Slerp(M3, M4, t).

 Posts: 83
 Joined: Thu Apr 24, 2014 2:27 am
Re: Multiplication between two slerped quaternion
I meant linear interpolation, so why it is wrong?

 Posts: 75
 Joined: Sun Aug 19, 2012 3:24 pm
 Contact:
Re: Multiplication between two slerped quaternion
Interpolating between two transformation matrices using simple linear interpolation results incorrect transformation matrix.
For example, let's consider two rotation matrices around X axis by 0 radians and pi radians.
These matrices are below:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
and
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Interpolating between these results an incorrect matrix.
For example using t = 0.5, The result is
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 1
This matrix crush all shapes to one dimensional shapes.
Therefore we should not use the linear interpolation and we can use spherical linear interpolation as one way.
* Note that in the above example, two quaternions are perfectly parallel, therefore we cannot define a plane in which an interpolated quaternion sweeps. In this case we might need to give an axis on which interpolation is considered.
For example, let's consider two rotation matrices around X axis by 0 radians and pi radians.
These matrices are below:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
and
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Interpolating between these results an incorrect matrix.
For example using t = 0.5, The result is
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 1
This matrix crush all shapes to one dimensional shapes.
Therefore we should not use the linear interpolation and we can use spherical linear interpolation as one way.
* Note that in the above example, two quaternions are perfectly parallel, therefore we cannot define a plane in which an interpolated quaternion sweeps. In this case we might need to give an axis on which interpolation is considered.

 Posts: 83
 Joined: Thu Apr 24, 2014 2:27 am
Re: Multiplication between two slerped quaternion
I see
thanks for clarification
considering "correct" interpolation, I'm still aware of why you think that multiple slerp is correct?
its transform(t) is proportional to t^n which seems wrong to me
thanks for clarification
considering "correct" interpolation, I'm still aware of why you think that multiple slerp is correct?
its transform(t) is proportional to t^n which seems wrong to me