Sign in to follow this  
JustChris

Skip meshes for rendering, using multiple instances

Recommended Posts

JustChris    150
If I was using instanced geometry for a scene and only wanted to render certain instances of a mesh, which is updated as the program runs, how do I skip the ones I don't want to render? Changing the amount in SetStreamSourceFreq() just ignores the ones from the end of the list. Thinking about that further, my best idea for a solution is to mark each instanced mesh as renderable or non-renderable in some array-like structure. And for every set of instance data in the vertex buffer, use it if it's renderable or do a swap with the last vertex in the buffer if it's not. The idea for that is to move all the renderables' data to the beginning of the vertex buffer so that updating the amount of instaces in SetStreamSourceFreq() won't render those. Would this be a good solution, or are there easier/more efficient ways to achieve what I need? Or is instancing actually getting in the way of the "skip meshes to render" problem?

Share this post


Link to post
Share on other sites
ET3D    810
Normally instancing has two buffers, one the geometry, the other the instance data. The instance data is normally dynamic, and would change every frame to include the relevant instances only.

Share this post


Link to post
Share on other sites
JustChris    150
Quote:
Original post by ET3D
Normally instancing has two buffers, one the geometry, the other the instance data. The instance data is normally dynamic, and would change every frame to include the relevant instances only.


I know this already, which is why I came up with the idea of reordering the the instance data. But from what you are saying, do you mean that I can resize the vertex buffer as well?

Share this post


Link to post
Share on other sites
feal87    238
Yep, just rewrite the instance buffer each time a change occur inside the instance list with Map...UnMap / Lock...Unlock with Discard. (an instance has become invisibile)

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