What is wrong with my vertex declaration below? I am using it with instancing. After adding TextureInformation to it, it renders weird and has an epileptical seizure.
public struct VertexInstance : IVertexType
{
public Matrix World;
public Color Color;
public Vector3 TextureInformation;
// I use arithmetic here to show clearly where these numbers come from
// You can just type 28 if you want
public static readonly int SizeInBytes = sizeof(float) * 23;
// Vertex Element array for our struct above
public static readonly VertexElement[] VertexElements = {
new VertexElement(0, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 0),
new VertexElement(sizeof(float) * 4, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 1),
new VertexElement(sizeof(float) * 8, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 2),
new VertexElement(sizeof(float) * 12, VertexElementFormat.Vector4, VertexElementUsage.TextureCoordinate, 3),
new VertexElement(sizeof(float) * 16, VertexElementFormat.Color, VertexElementUsage.TextureCoordinate, 4),
new VertexElement(sizeof(float) * 20, VertexElementFormat.Vector3, VertexElementUsage.TextureCoordinate, 5)
};
public static VertexDeclaration Declaration
{
get { return new VertexDeclaration(VertexElements); }
}
VertexDeclaration IVertexType.VertexDeclaration
{
get { return new VertexDeclaration(VertexElements); }
}
}
