When working with multiple texture coordinates that I have defined in my vertex factory, when I go to the material editor the index do not match up. My Init()
code in my vertex factory is as follows:
void Init(const FMyMeshVertexBuffer* VertexBuffer)
{
check(!IsInRenderingThread());
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
InitMyMeshVertexFactory,
FMyMeshVertexFactory*,VertexFactory,this,
const FMyMeshVertexBuffer*,VertexBuffer,VertexBuffer,
{
// Initialize the vertex factory's stream components.
DataType NewData;
NewData.PositionComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer,FMyMeshVertex,Position,VET_Float3);
NewData.ColorComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer,FMyMeshVertex,Color,VET_Color);
NewData.TextureCoordinates.Add(FVertexStreamComponent(VertexBuffer,STRUCT_OFFSET(FMyMeshVertex,TextureCoordinate), sizeof(FMyMeshVertex),VET_Float2));
NewData.TextureCoordinates.Add(FVertexStreamComponent(VertexBuffer,STRUCT_OFFSET(FMyMeshVertex,Size), sizeof(FMyMeshVertex),VET_Float2));
NewData.TextureCoordinates.Add(FVertexStreamComponent(VertexBuffer,STRUCT_OFFSET(FMyMeshVertex,MyType), sizeof(FMyMeshVertex),VET_Float2));
NewData.TangentBasisComponents[0] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer,FMyMeshVertex,TangentX,VET_PackedNormal);
NewData.TangentBasisComponents[1] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer,FMyMeshVertex,TangentZ,VET_PackedNormal);
VertexFactory->SetData(NewData);
});
}
Now when going to my material, I’d expect TextureCoordinate
to be at index 0, Size
to be at index 1, and MyType
to be at index 2. When I go to work on my material, the indexes are 0, 2, 4 respectively. Am I setting something wrong? Should I be inserting instead of adding to make sure the indexes are exactly as I want them?