Original Post
Hello, I was just reading up on occlusion culling and I was thinking on how I might combine that with my hardware instancing sample, but I don't see how that would be possible when rendering a lot (50.000+) of small meshes. Because I'm using instancing, I'd first need to come up with an efficient way to turn the rendering of specific objects on and off. Trivial as that is for normal rendering, it seems a big downside to instancing. For true (SM3) hardware instancing, I'd have to remove the instance data of the objects that shouldn't be rendered from the data vertex buffer. It shouldn't be too hard to implement, but it introduces a CPU load to a technique that's supposed to offload completely to the GPU. For shader instancing (GPU batch drawing) it would be a bit more efficient, since I can work directly on the instance data array. But I'd need to check the instance data entries one by one and pass the ones that should be rendered to the effect, so it'll still add some overhead. And even with that out of the way, the typical occlusion query is probably undoable (if I understand it correctly), since I can't render the bounding meshes for the 50.000+ instances one-by-one to perform the query, as doing that would remove the whole purpose of the instancing. I might be able to use a bounding mesh for performing the occlusion query for multiple instances at once, but it seems a bit of a messy workaround. The same problem applies to view frustrum culling. I think the large number of objects/instances makes it undesirable to check them all against the frustrum, so I'd have to go mess with octrees to get this to work efficiently. It may be doable, but I doubt it would improve the overall performance, considering the overhead of the culling technique AND the overhead of specifying which instances should be rendered. Does anyone have any experience with this problem? From what I can tell, I don't think culling techniques in general can improve the performance of instancing much when rendering a large number of small meshes (for a few large instanced models, I do see that it can be an improvement). Any insights would be very much appreciated, since I got a feeling I'm missing something here :)