View Full Version : Auto-culling?

01-28-2016, 03:28 PM
I don't know what constitutes a 'Beginner' question, but if I have to ask then odds are it is one. :/

I'm developing an engine that currently instance-draws many different grass objects on the screen (and nothing else). When I rotate the camera so that the grass is off-screen, the frame rate increases *VERY* significantly (measured by checking a timestamp at the beginning of each rendering cycle. Problematic?)

The real problem that I'm wrestling with is that it happens even though I do not have culling set up. As I understood it, if the object lands off-screen the engine still goes through the rigo mora of calculating all the piece-parts as if it were to be painted in earnest. Clearly my understanding is off. *Something* about OpenGL knows my objects aren't being viewed, but I don't understand what it is.

Any initial suggestions? I'm hoping it's obvious before I need to copy-paste code.

carsten neumann
01-28-2016, 03:49 PM
If the object is off-screen no rasterization has to be performed by the GPU, so it never has to execute the fragment shader or touch the framebuffer memory. This is performed by the fixed function clipping step (after all vertex processing stages) where primitives are clipped against the view frustum.

So even though your code goes through all the same steps as if the object ended up being visible and the vertex stages have to perform the same work, any step after clipping can be skipped by the GPU.

01-28-2016, 10:12 PM
Interesting! That was definitely not explained in the intro book I read, but then again it was a short book. Thank you for clearing that up!