The question is probably very banal, but I did not find an answer to it. I use DirectX 9 (I can't do it higher due to hardware specifics). I have a model not in my format that I need to render. The format stores the positions of the vertices and each vertex has a material index, the material index can be used to get the texture name. By the name of the texture, I load the desired file and get IDirect3DTexture9*. The question is, how do I get the texture index for a particular vertex in a pixel shader?
If I understand correctly, I have to create an array of textures in the pixel shader:
sampler MyTextures[16];
float4 main(PSInput input) { return tex2D(MyTextures[input.MaterialIndex], input.UV); }
Set texture to each cell before rendering the model (call IDirect3DDevice9::SetTexture), and then extract the index from the input data and get the color of the pixel. But how can I put an index in the incoming data if there is no suitable slot in the vertex declaration for this?
I mean there is no "D3DDECLUSAGE_MATERIALINDEX" here:
https://docs.microsoft.com/en-us/windows/win32/direct3d9/d3ddeclusage
What should I do?