Multiple Stream Buffer?

Started by
4 comments, last by superpig 19 years, 4 months ago
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]
Advertisement
Can't you just ignore the parts that you don't need in the vertex shader?

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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.
* 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...
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.

Game Programming Blog: www.mattnewport.com/blog

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.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement