Sign in to follow this  
MIKI_hack

Multiple Stream Buffer?

Recommended Posts

MIKI_hack    122
Hi, guys. I have a vertex buffer representing a mesh-object. This buffer contain usual vertex component (position, normal, texcoord, ...) and render it using a generic shader (I use dx9). Now i want to render the same object to a render target texture i.e. for shadow mapping or environment mapping (also by shaders), that obviously use different vertex-components. My questions is : what is the fast (or best) way to manage vertex beffer data for this situations? I mean, i should use variuos stream-source as dx9 suggest, or is better duplicate vertex-buffer using different vertex-component? O maybe are there any other best technique? [Edited by - MIKI_hack on November 24, 2004 8:17:48 AM]

Share this post


Link to post
Share on other sites
Moagly    160
If you use the D3DX Mesh class you can clone the mesh to a particular vertex format, you just need to know which FVF or vertex declaration you want to clone the mesh to and you can ensure that the vertex stream will contain the correct elements for your shader, check out the DX SDK for CloneMeshFVF can't remember off hand exactly how to use it, but think the SDK is pretty self explanatory about it.

Share this post


Link to post
Share on other sites
MIKI_hack    122
* superpig :
Yes, i should. But if i have meshes with different vertex-component (i.e. static geometry and dynamic mesh) i should have more than one shadow-shader for example, because shader-vertex format must match exact input vertex format.

* Moagly :
I read about it, but i don't want to use D3DX extension. But my idea could be something similar...

Share this post


Link to post
Share on other sites
mattnewport    1038
Quote:
Original post by MIKI_hack
* superpig :
Yes, i should. But if i have meshes with different vertex-component (i.e. static geometry and dynamic mesh) i should have more than one shadow-shader for example, because shader-vertex format must match exact input vertex format.

I'm not sure I follow exactly what you're saying there but generally the vertex format for the model doesn't have to exactly match the input to the shader. The model must have every element required by a vertex shader in order to use that shader but it can also have extra elements that the shader doesn't use. If you have a mesh that needs to be rendered by a number of different shaders one option is to just ensure that the vertex buffer(s) have the union of all the vertex components required by all the shaders it will be rendered with. There may be some performance implications to using a fatter vertex format than a particular shader actually needs but it's not generally a big deal.

Share this post


Link to post
Share on other sites
superpig    1825
What mattnewport said.

You can also use vertex declarators to help out to a certain extent - I'm not sure if they allow you to define structures that aren't tightly packed. If they do, then you could create a declarator which selects only the inputs you need for a particular shader, wiring them into the desired shader inputs.

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