Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vertex Shader implementation of the FBX skinning method

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
853 Views, 3 Replies

Vertex Shader implementation of the FBX skinning method

The FBX method of skinning is not the same as standard skinning and Direct3D and OpenGL.

In FBX, you are skinning the bone matrices and in Direct3D/OpenGL you are skinning the positions.

Direct3D/OpenGL skinning method:


Output.pos = (0,0,0);
for(int iBone = 0; iBone < nBones; iBone ++)
{
Output.pos += Input.pos * matrixPalette] * afBlendWeights;
}


Direct3D shader:


S_SKIN_OUTPUT VS_Skin( const VS_SKIN_INPUT vInput, int iNumBones )
{
VS_SKIN_OUTPUT vOutput = (VS_SKIN_OUTPUT) 0;

float fLastWeight = 1.0;
float fWeight;
float afBlendWeights = (float) vInput.vBlendWeights;
int aiIndices = (int) D3DCOLORtoUBYTE4( vInput.vBlendIndices );

for( int iBone = 0; (iBone < 3) && (iBone < iNumBones - 1); ++ iBone )
{
fWeight = afBlendWeights;
fLastWeight -= fWeight;
vOutput.vPos.xyz += mul( vInput.vPos, amPalette ] ) * fWeight;
vOutput.vNor += mul( vInput.vNor, amPalette ] ) * fWeight;
}

vOutput.vPos.xyz += mul( vInput.vPos, amPalette ] ) * fLastWeight;
vOutput.vNor += mul( vInput.vNor, amPalette ] ) * fLastWeight;

return vOutput;
}



for FBX, you sum the matrix

float4x3 BoneMatrix = 0;

for(int i = 0; i < nBones; i++)
{
BoneMatrix += matrixPalette ] * afBlendWeights;
}
Output.pos = Input.pos * BoneMatrix *g_mWorld;



FBX shader in Direct3D



VS_SKIN_OUTPUT VS_SkinTotal1( const VS_SKIN_INPUT vInput, int iNumBones )
{
VS_SKIN_OUTPUT vOutput = (VS_SKIN_OUTPUT) 0;

float fLastWeight = 1.0;
float fWeight;
float afBlendWeights = (float) vInput.vBlendWeights;
int aiIndices = (int) D3DCOLORtoUBYTE4( vInput.vBlendIndices );

float4x3 BoneMatrix = float4x3( float3(0,0,0) , float3(0,0,0) , float3(0,0,0), float3(0,0,0) );

for( int iBone = 0; (iBone < 3) && (iBone < iNumBones - 1); ++ iBone )
{
fWeight = afBlendWeights;
fLastWeight -= fWeight;
float4x3 BoneMatrixScaled = amPalette ];

BoneMatrixScaled = mul(BoneMatrixScaled, fWeight);
BoneMatrix = BoneMatrix + BoneMatrixScaled;
}

float4x3 BoneMatrixScaled = amPalette ];
BoneMatrixScaled = mul(BoneMatrixScaled, fLastWeight);
BoneMatrix = BoneMatrix + BoneMatrixScaled;

vOutput.vPos.xyz = mul( mul(vInput.vPos, BoneMatrix), g_mWorld );
vOutput.vNor = mul( mul(vInput.vNor, BoneMatrix), g_mWorld );

return vOutput;
}
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

It`s good. Doug, write please, how to get bone weights and linked vertices. In examples, i found only Deformer.
Message 3 of 4
Anonymous
in reply to: Anonymous

It`s good. Doug, write please, how to get bone weights and linked vertices. In examples, i found only Deformer.



See this thread:
area.autodesk.com/forum/Autodesk-FBX/fbx-sdk/getting-bind-pose/
Message 4 of 4
Anonymous
in reply to: Anonymous

Thank you. I will try it.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report