I'm still in the planning phase for a hobby abstract renderer, and i'm wondering how i should handle multiple vertex types and different shader inputs. (This is my first graphics project, so cut me some slack for lack of knowledge :) ).
What I want to to do is have the vertices be typeless, and have my model file specify "channels" of attributes EX: position, color, normal, binormal, tanget, etc. These channels would have string identifiers and stride values. On the shader side, i would like each shader program to specify which "channels" it requires via the identifier. Vertex Buffers would be compatible with the shaders if they had all the attributes required by the shader.
this is all abstract so I must be able to implement the functionality in most API's. However, taking a look over at D3D11, it looks like i would have to create a new Input layout per Vertex Buffer/ Shader COMBINATION. It would also mean some sort of goofy cataloguing system that goes, "if you have this specific combination of attribs, and the shader requires this specific combination of attribs, then use this layout", which makes me a little queasy thinking about it :\ . The number of input layouts would grow exponentially with more combinations.
The other solution would be to create and delete a new input layout EVERY time you wish to render. same queasiness -_-. Was D3D11 intentionally trying to force every vertex buffer in your design to have the same type?
Does anyone have a better suggestion? the main parameters i would like are the channel based vertex buffers, and the channel receiving shaders.
Answer
This sounds like you are talking about a Flexible Vertex Format (FVF). This allows you to define you vertexes as you would like, though this is for D3D9 rather than for D3D11.
One thing to keep in mind is not to have things too dynamic. The reason is, the more vertex formats that are the same, the more models that share the same texture/shader/material etc... the faster things can be rendered.
If you are going to use standard model formats, a common FVF should be all you need:
XYZ UV
Regarding shaders, they are custom built for specific models and vertex formats. For best performance, they expect things to be precise, rather than, "Which FVF am I using?"
Performance is King.
No comments:
Post a Comment