Sign in to follow this  
becoolnike

draw multi textured quads with a single pass

Recommended Posts

I was playing around Index buffers so i created a index of 4 textured quads, i lock the index buffer, write it, unlock it, and i am wonder if there is a way to render multi textured quads without calling 4 times to DrawIndexedPrimitive and setTexture because every quad has a diffrent texture.

Share this post


Link to post
Share on other sites
If you use a dynamic vertex buffer, you can pre-transform your quad vertices and stick all of the vertices into a single vertex buffer. Then you can draw them all in one call. You can also use shader constant instancing or hardware instancing (SM3.0 and SM4.0 only) to render your quads.

As for different textures, you have a few options. One option is to combine all of your textures into a single texture atlas. Then you just use add an offset to your U or V coordinates to control which texture you sample from. In ps_3_0 you can use dynamic branching to choose which texture you sampler from, but this may not be performant on all hardware. In ps_4_0 (DX10), you have access to texture arrays which makes things even easier.

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