Sign in to follow this  
CDProp

Any need for more than one vertex declaration, usually?

Recommended Posts

I was just wondering, because my rendering stuff is set up so that you can have a separate vertex type for each material type, but I'm finding it easier to just create one master vertex type (that contains everything: position, color, normals, and multiple sets of texture coordinates) and then I just use that for everything. If the shader needs it, it uses it, otherwise it doesn't.

Share this post


Link to post
Share on other sites
In a large scale engine you'd want to have multiple vertex types.

Changing vertex declaration is moderately expensive, so you probably want to avoid it where possible. However, if you find that you're bandwidth limited (Limited by the amount of data you're throwing across the CPU -> GPU bus per frame), then getting rid of all of the extra stuff in your vertex struct that's not being used could be a worthwhile saving.

So short answer: In the short term; maybe not, but in the long term; yes, you'll want to strip all the dross out of your vertex struct.

Share this post


Link to post
Share on other sites
You could potentially (though I haven't tried it) use a large vertex declaration without requiring more data (except a small constant overhead) by setting the stride size to the date size, instead of the vertex declaration size.

Share this post


Link to post
Share on other sites
I found a large reduction in video memory requirements by stripping out all of the unnecessary data from my vertices. There's really no point in storing information that you are never going to use, particularly in limited video memory. I also saw a decent frame rate boost by doing this, and its let me increase the size of my scenes significantly.

Batching your rendering on the vertex declaration used is definitely a good idea, and not too hard to do.

Plus, you can leave yourself the option of using some truly exotic vertex formats if you have any unique or strange needs for a particular shader effect, instead of having to say add a 3rd texture coordinate to everything, you only have to do it for that one effect that requires it.

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