Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


[SOLVED] Dual Quaternion Issue


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 zacharias   Members   -  Reputation: 119

Like
0Likes
Like

Posted 20 February 2012 - 06:43 PM

Hi guys!

After several hours of debugging i decided to ask you for help ^^
I´ve implemented skeletal animation with dual quaternions in my engine, but it looks like something in the blending process is still wrong.

this is how it should look, beautiful, isn´t it?
1.jpg

and this is how it actually looks like in my engine.
2.jpg
you can see the bones drawn as black lines, the squares indicate joints.

detail, at a lower angle
3.jpg

here is my vertexshader, calculating the blending. as you can see, i split up the dual quaternion in rotation- and translationpart. both are calculated in the engine. the bonePos is just the joint position. i checked the uniform values, everything is fine.

#version 120

// (C) Zacharias :-P

attribute vec4 weights1;
attribute vec4 gl_MultiTexCoord0;
uniform vec3 bonePos[4];
uniform vec4 boneDQuatR[4];
uniform vec4 boneDQuatT[4];

vec3 calculateBlendPosition(vec3 position, vec4 blendDQR, vec4 blendDQT)
{
//blendDQR /= length(blendDQR);
		vec3 blendPosition = position + 2.0*cross(blendDQR.xyz, cross(blendDQR.xyz, position) + blendDQR.w*position);
		vec3 trans = 2.0*(blendDQR.w*blendDQT.xyz - blendDQT.w*blendDQR.xyz + cross(blendDQR.xyz, blendDQT.xyz));
		blendPosition += trans;
		return blendPosition;
}
void main(void)
{
// just pass the texture for now
gl_TexCoord[0] = gl_MultiTexCoord0;
// skinning
vec4 v4 = gl_ModelViewMatrix * gl_Vertex;
vec3 v = v4.xyz;

// x y z w
vec4 r = vec4(0.0,0.0,0.0,0.0);
vec4 t = vec4(0.0,0.0,0.0,1.0);

for(int i=0;i<4;i++)
{
  v -= bonePos[i]*weights1[i];
  r += boneDQuatR[i]*weights1[i];
  t += boneDQuatT[i]*weights1[i];
}

v = calculateBlendPosition(v, r, t);
for(int i=0;i<4;i++)
{
  v += bonePos[i]*weights1[i];
}

gl_Position = gl_ProjectionMatrix * vec4(v, 1.0);
}

i tried out several things like normalizing etc, but everything seems to be fine.
btw the blending gets better at the 2nd joint, but is still wrong.

THX
Zachy

Sponsor:

#2 zacharias   Members   -  Reputation: 119

Like
2Likes
Like

Posted 23 February 2012 - 07:31 AM

Solved. Rotation centers should be implemented while creating the quats, not in the shader by offset. The weighting of offsets causes those artefacts.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS