I've got a bit of a conundrum that is just flat out stumping me. Let's say i have a couple of shaders all with different vertex types like this:
// light shader
struct vertexInputType
{
float4 position : POSITION;
float2 tex : TEXCOORD0;
float3 normal : NORMAL;
};
// color shader
struct vertexInputType
{
float4 position : POSITION;
float4 color : COLOR;
};
// bump mapping shader
struct vertexInputType
{
float4 position : POSITION;
float2 tex : TEXCOORD0;
float3 normal : NORMAL;
float3 binormal : BINORMAL;
float3 tangent : TANGENT;
};
Now let's say i have a model with all of this data available. I can't exactly have it all be in the same buffer and render with all 3 as i choose because the data isn't laid out correctly for all of them. I only see two options to make this possible, both of them just as painful.
1) i could have a big buffer in ram that holds all the data, and then every draw call, i grab from the shader object, the vertex type and create a new vertex buffer with the correct information. This, as you can see, would be HORRIBLY slow.
or...
2) i could create multiple ID3D11Buffers when the model is initialized, where one buffer has the position and color, one has position, texcoord, and normal, one has position, texcoord, normal, binormal, and tangent, and also as many buffers needed for any other vertex types the model has information for. This in comparison, obliterates your available vram, making this a nogo as well.
I can't see any other way of doing this. How do you other d3d guys do this?