Sign in to follow this  
littlekid

How to selectively enable/disable a portion of Instancing

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

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