Jump to content
  • Advertisement
Sign in to follow this  

Blend Indices Are Empty After Migrating To Monogame

This topic is 838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am migrating an XNA 4 project to MonoGame. I have a problem with a skinned shader, the blendindices have zero values when passed to the vertex shader. I have used colored pixel debugging to determine this, and compared the results with the original XNA project.

The shader was upgraded from SM 2 to SM 4 during the migration.


The vertex buffer contains the expected values before the Draw call.
Here is the input struct which is contained in the vertex buffer:

 // This is passed into our vertex shader from Xna
    struct VS_INPUT
// This is the position of the vertex in the model file
float4 position : SV_Position;

// The vertex normal
float3 normal : NORMAL0;

// This is the texture coordinate for the vertex in the model file
float2 texcoord : TEXCOORD0;

// These are the indices (4 of them) that index the bones that affect
// this vertex.  The indices refer to the MatrixPalette.
half4 indices : BLENDINDICES0;

// These are the weights (4 of them) that determine how much each bone
// affects this vertex.
float4 weights : BLENDWEIGHT0;

In the model processor, the blend indices for each vertex are packed into a Byte4 struct like so:


 Vector4 bi = new Vector4();
 bi.X = count > 0 ? indexer.GetBoneIndex(bwc[0].BoneName) : (byte)0;
 bi.Y = count > 1 ? indexer.GetBoneIndex(bwc[1].BoneName) : (byte)0;
 bi.Z = count > 2 ? indexer.GetBoneIndex(bwc[2].BoneName) : (byte)0;
 bi.W = count > 3 ? indexer.GetBoneIndex(bwc[3].BoneName) : (byte)0;
 indicesToAdd[i] = new Byte4(bi);

All of this works perfectly in XNA. I am wondering if the problem could be in marshalling data from Byte4 to half4. The latter structure is twice the size. But if I change it to float4, it makes no difference.

Edited by captain_crunch

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!