Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am creating a basic XNA recreation of Minecraft. My current problem is that my "Steve" model, which is skinned with an armature using vertex groups to deform, is showing up disfigured beyond all reason. I am using a custom shader with skinning imported from the SkinnedEffect from the StockEffects example. I'm sure the effect itself works fine and that my model's groups and weights are the problem. A link to another forum with the same question is here, since I cant post pictures or more than two links.

Here are some details about my model: The version of Blender I use is 2.6. Pay no attention to the corner-looking piece. That's just there for size comparison when I built him. I export to .fbx with only the mesh and armature selected. No options are selected other than "Export Selected" and "Apply Modifiers". Smoothing is off, Forward is -Z Forward and Up is Y Up. Again, I think the problem is the vertex groups and wights. Everything deforms properly in Blender, but not in XNA.

My Custom Shader:

//VertexShader
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
        VertexShaderOutput output;
        Skin(input, NumBones);
        float4x4 worldViewProj = mul(mul(World, View), Projection);
        output.Position = mul(input.Position, worldViewProj);
        float4 normal = mul(input.Normal, WorldInverseTranspose);
        float lightIntensity = dot(normal, DiffuseLightDirection);
        output.Color = saturate(DiffuseColor * DiffuseIntensity * lightIntensity);
        output.Color.a = 1;
        output.TextureCoordinate = input.TextureCoordinate;
        return output;
}

//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);
}
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.