Skip meshes for rendering, using multiple instances

Started by
2 comments, last by feal87 14 years, 11 months ago
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?
Electronic Meteor - My experiences with XNA and game development
Advertisement
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.
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?
Electronic Meteor - My experiences with XNA and game development
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)

This topic is closed to new replies.

Advertisement