XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

Modify Skinning Sample To Allow More Bones (float4x4 -> float 4x3)

Last post 04/11/2009 8:23 by AlectoPerfecto. 3 replies.
  • 02/11/2009 14:45

    Modify Skinning Sample To Allow More Bones (float4x4 -> float 4x3)

    Hello,

    My models require about 70 odd bones... By default the Skinning Sample only supports 59 because of a shader model 2.0 limitation.

    I have heard that 59 can be increased by using float4x3 rather than float4x4...

    Could anyone please help me step-by-step to change this? I am quite a capable coder but I cannot seem to get this to work.

    Its certainly not as simple as setting float4x3[bones] like originally suggested.

    Cheers,

    Karsten
  • 02/11/2009 21:32 In reply to

    Re: Modify Skinning Sample To Allow More Bones (float4x4 -> float 4x3)

    It actually quite simple. All you need to do is use float4x3 instead of float4x4 in shader. You don't need to change anything on C# code side at all (Of cause except MaxBone constant value). Effect class takes care of converting Matrix array to float4x3 array for you!! 

    If you are using our SkinningSample code, you only need to modify 3 locations in SkinnedModel.fx and change MaxBones value to 79 from 59. The following code is original code ( "// ..." means there is other codes ): 

     

    float4x4 Bones[MaxBones];  
     
    //...  
     
    VS_OUTPUT VertexShader(VS_INPUT input)  
    {  
        // ...  
          
        // Blend between the weighted bone matrices.  
        float4x4 skinTransform = 0;  
          
        //...  
          
        // Skin the vertex position.  
        float4 position = mul(input.Position,skinTransform);  
         

    You have to change those lines like below (changed part are under lined):

    float4x3 Bones[MaxBones];  
     
    //...  
     
    VS_OUTPUT VertexShader(VS_INPUT input)  
    {  
        // ...  
          
        // Blend between the weighted bone matrices.  
        float4x3 skinTransform = 0;  
          
        //...  
          
        // Skin the vertex position.  
        float4 position = float4( mul(input.Position,skinTransform), 1 );  
         

     

     

     

  • 03/11/2009 3:36 In reply to

    Re: Modify Skinning Sample To Allow More Bones (float4x4 -> float 4x3)

    It is almost that easy -- you just have to make sure you also change the data you send to the shader to match the float4x3 that you use. The diffuseonly-skinned.fx shader that comes with the archer.x sample in kW Animation uses this mechanism, for example.

    You can get even more bones by packing a position and uniform scale in one float4, and a quaternion in another float4, for a total of two vertex shader constants per bone.
    You can also provide data in a floating-point texture for vertex texturing instead of shader constants. However, that may perform poorly on various kinds of hardware.
    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 04/11/2009 8:23 In reply to

    Re: Modify Skinning Sample To Allow More Bones (float4x4 -> float 4x3)

    Wow I had no idea that it was that easy =p.  I was just going to say that you could split your mesh up into two meshes, duplicating the skirt that connects the two parts, having half your bones in the first fbx file and half your bones in the second one, you can use the skinningsample3.1 extensions sample to find the bone transforms from from the last bone in the first group, and setting them equal to the first bone in the second group. 
Page 1 of 1 (4 items) Previous Next