Shaders and meshes

Started by
3 comments, last by feal87 14 years, 11 months ago
Hy. I'm still creating some mesh in dx10. The shader that must render these meshes is the same(for the vertex layout and behaviour) , but i must draw all the meshes. I 'have created a meshes class. This mesh class contains a vertexbufer and an indexbuffer , but is sufficent for the render ? I create also a collection class with an effect(shader) var member , a device var member and i adding all the meshes objects into a vector in the collection , but for the render i can use the same effect shader? I can link the index and the vertex buffer of the mesh class and then rendering with the shader(effect is the same word?) how? Thanks.
Advertisement
i'm try to read in more depth the sdk tutorial , but
I seem to have read that there must be a shader tecnique for each vertexbuffer and indexbuffer.
But if i would draw 2 meshes identical i must create 2 effect thecniques is correct?
Then the interface between the data(the mesh in directx9) and the video render is the shader and the tecniques?

But if i would create a mesh i must compile the shader , create vertex and indexbuffers and then

g_pTechniqueRender->GetPassByIndex( 0 )->Apply( 0 );g_pd3dDevice->DrawIndexed( 36, 0, 0 );


but if i have a lot of meshes i must have a lot of shadertecnique!

And if i have created a "material water shader" , for example that display a meshes in the water material if i have rendered a "cube of water" i can with the same shader render a water sphere ?
The difference is only on the vertex and the index buffers , why i must redefine the effect?
Thanks.
You do not need to redefine the shader, you can use the same if you want the same effect and the Input Layout is the same.
thanks for the ready responce.
But how i resuse the same shader ?
yes , the effect is the same and also the layout but I must change at least the vertex and index buffer.
How in dx10?
Quote:Original post by giugio
thanks for the ready responce.
But how i resuse the same shader ?
yes , the effect is the same and also the layout but I must change at least the vertex and index buffer.
How in dx10?


Just like you set them in the first time. Set them to the input assembler with ID3D10Device::IASetVertexBuffers and ID3D10Device::IASetIndexBuffer?
you just need to apply the effect one time and then rendering the two meshes changing the vertex/index buffers between the draws...

If you are using the mesh class, i think you just need to call the draw after applying the shader, the class will do the rest. (I'm not sure cause i have my own system for rendering based over raw vertex/index buffers)

This topic is closed to new replies.

Advertisement