Vertex Formats

Started by
2 comments, last by beebs1 14 years, 10 months ago
Hiya, I'm wondering if someone could give me some advice on my renderer design :) I'm loading mesh data from files, and the different HLSL shaders in my game need different vertex formats as input. I can see several ways of making the vertex formats match, but none seem ideal - I'm really hoping someone can lend their opinion. I could just stuff every conceivable vertex attribute into each mesh, so everything submitted to the renderer is in the same format. This seems very wasteful though, so it's not a great solution. I think another way would be to use a mechanism similar to Yann L's. I believe in his system every shader is implemented as a DLL, so the vertex formats required can just be hard-coded in. Each DLL will know what format it needs, and any missing attributes can be generated for each mesh as required. It seems like this would generate a huge amount of shader DLLs, and it doesn't seem too artist-friendly. A third way would be to determine the required format from the HLSL file itself, and then fill in the missing attributes. As far as I know this is only possible in D3D10 though (reflection?), and I need to target D3D9... I'm sure this must be a common problem. Can anyone say how they solve this? Thanks in advance for any help! Cheers, James
Advertisement
In my engine I have a personal mesh format that stores its own vertex declaration inside itself. I think its the most efficient way. (If i'm correct the .x file format do the same...)
I'd like to know how people do as well.

Here's how I tried to solve the problem, with dx9 : my fx files contain the input struct and a dummy global variable of that struct. You can't access the struct directly from your app, but you can access the global variable.
So in my app I can get a handle on the dummy var, use GetParameterDesc to know how many elements are in the struct. Then a loop to parse the struct members, giving the name, type, semantic, etc.
Thanks.

So GetParameterDesc() lets you determine the input structure? Interesting, I'll have to have a look at that.

This topic is closed to new replies.

Advertisement