user1760770
user1760770

Reputation: 395

OpenGL instanced rendering - frustum culling

I'm drawing large amount of cubes (100 000+) using glDrawElementsInstanced(). Due the performance reasons I'd like to implement frustum culling, but I'm not quite sure how to do that when I'm using instancing. From what I know, the only way to access individual instance of object is in shaders, so I assume I have to do the culling there. I'm not quite sure how to do so. Can anyone point me to any tutorials?

Upvotes: 1

Views: 1267

Answers (1)

Robert Rouhani
Robert Rouhani

Reputation: 14668

Trying to do culling in the vertex shader is way too late in the process. You have to feed the cube's transforms to the shaders somehow, just take that data and set up a Bounding Volume Hierarchy. Then only draw the instances that pass the frustum culling.

Upvotes: 4

Related Questions