Jump to content
  • Advertisement
ProgrammerDX

How to build Skinning Matrix with Blended.

Recommended Posts

Hi!

So I'm struggling with this problem about skinning.

Let's say you have a vertex that is skinning blended to 4 bones. How do you build the bone matrix / transform in vertex shader?

Can you make a 'total' bone matrix based on the sum of bone matrices according to their weights together. Like in Urho3D:

//Skin() Method
void Skin(inout VertexShaderInput input, uniform int boneCount)
{
        float4x4 skinning = 0;
        [unroll]
        for (int i = 0; i < boneCount; i++)
        {
                skinning += Bones[input.Indices[i]] * input.Weights[i];
        }
        input.Position = mul(input.Position, skinning);
}

 

Or what I see in every topic on gamedev, where you multiply the bone matrix for each vector position multiplied by the weight, like here:

https://www.gamedev.net/forums/topic/549125-hlsl-skinning/

 

VS_OUTPUT_BASE Out = (VS_OUTPUT_BASE) 0;

    float3 Pos = 0.0f;
    float4 src = float4(inPos.xyz,1.0f);

   Pos += mul(u_pose[int(indicies.x)] ,src) *  weights.x/255;
   Pos += mul(u_pose[int(indicies.y)] ,src) *  weights.y/255;
   Pos += mul(u_pose[int(indicies.z)] ,src) *  weights.z/255;
   Pos += mul(u_pose[int(indicies.w)] ,src) *  weights.w/255;

Out.Pos  = mul(u_model_view_proj_matrix,float4(Pos,1.0f) );

 

I think the first method is right, but I'm still curious. I think it's right because with the second method it's impossible to build the vertex buffer with vector positions that are multiplied by the inverse of the bind pose bone matrix, but it's still weird that it's out there being discussed.

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!