Sign in to follow this  
beebs1

Vertex Formats

Recommended Posts

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

Share this post


Link to post
Share on other sites
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...)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this