Jump to content
  • Advertisement
Sign in to follow this  
becoolnike

draw multi textured quads with a single pass

This topic is 3344 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!