I'm writing an DirectX11 game.
About 60% of my game models (or "of my vertices") have:
- Position
- Texture coordinate
Some of them use:
- Position
- Texture coordinate
- Normals
And few of them:
- Position
- Texture coordinate
- Normals
- Tangents
- BiTangents
And I have about 10 shaders:
- 3 of them assume that vertices have just position and texture coordinates
- 5 that they also have normals
- 2 make use of tangent/bi-tangent info
The question is: should I create 3 vertex structures and 3 D3D11_INPUT_ELEMENT_DESC
arrays for them (option 1)? Or create only one, universal vertex structure (the last one, 5 members) and 1 D3D11_INPUT_ELEMENT_DESC
for it (option 2)?
What I see:
Option 1:
- No unused data will be transfered to shader - e.g. 60% of models will be rendered with simple shader that don't calculate normal maps and we will send to him just position/texture coordinate.
Option 2:
- Only one input structure, no need to switch vertices types - simpler code, maybe faster (no switching)?, no need to bother if new shader needs 1st, second or third structure (we can just pass everything to it and it will decide which members to use).