Jump to content

  • Log In with Google      Sign In   
  • Create Account


CppPerson

Member Since 17 Jul 2012
Offline Last Active Mar 09 2013 04:35 PM
-----

#4960412 [SOLVED] Dual Quaternion Skinning failing on blend

Posted by CppPerson on 18 July 2012 - 04:32 AM

For anybody who might have similar problems in the future, this is where I started on the optimisations:

float4 MultiplyPure(float3 a, float4 b)
{
   // lhs is a pure quaternion, rhs is a quaternion, so a.w=0
   return float4(b.w * a + cross(a, b.xyz), -dot(a, b.xyz));
}
float3 MultiplyConjugate3(float4 a, float4 b)
{
   // perform conjugate on lhs before multiplying, discard result.w
   return a.w * b.xyz - b.w * a.xyz + cross(-a.xyz, b.xyz);
}
float3 DQTransformPoint(float4 Qr, float4 Qd, float3 pt)
{
   // Vector transform pt by rotation Qr (pvp')
   float3 p = MultiplyConjugate3(Qr, MultiplyPure(pt, Qr));
   // t = 2QdQr*
   float3 t = 2 * MultiplyConjugate3(Qr, Qd);
   return p + t;
}

which reduces to:

float3 DQTransformPoint(float4 Qr, float4 Qd, float3 pt)
{
   float3 p = pt + 2 * cross(-Qr.xyz, Qr.w * pt + cross(pt, Qr.xyz));
   float3 t = 2 * (Qr.w * Qd.xyz - Qd.w * Qr.xyz + cross(-Qr.xyz, Qd.xyz));
   return p + t;
}

This is a subtle re-arrangement of the source paper's results which could have been achieved through guesswork. It was more fun this way Posted Image


PARTNERS