Jump to content
  • Advertisement
Sign in to follow this  
littlekid

How to selectively enable/disable a portion of Instancing

This topic is 3759 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

Hi, I am currently using hardware instance. My indexed mesh data is contain in VertexBuffer1(stream 0), and the instance data is contain in VertexBuffer2(stream 1). Lets say for example I have 10 instances data in VB2. However, my spatial tree found that the 4th and 6th instances are not visible on the screen. Is there anyway I can tell Directx to skip the 4th and 6th instances? Another problem I have is how do I add more instances? At the start I only have 10 instance, hence I create a VB of that size, in the middle of the program, I suddenly need another 4 more instance, should I dump the original VB and recreate a new one? Is there a elegant way of handling such cases? Lastly how should I handle my VB if my instances data keep changing? for example, multiple instance of a NPC characters that keeps walking around, hence the World Matrix in the instance buffer need to be constantly updated. Thanks

Share this post


Link to post
Share on other sites
Advertisement
The instance data is typically updated often. As you noticed, it's a replacement for writing shader constants. So don't worry about it. Create a buffer that's large enough for what you expect (so you don't need to enlarge it, which is costly), and when you need to change the data, lock it with "discard" and write what you need. In your first example, this would be the data for the 8 instances that you want to draw (those other than the 4th and 6th instances).

Share this post


Link to post
Share on other sites
Hi thanks for the replies, from what you have written, does it mean that the instance VB is better off created as dynamic?

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!