iDevGames Forums
GL backface culling - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: GL backface culling (/thread-7807.html)

GL backface culling - Tobi - Apr 19, 2002 10:16 AM

Hi folks,

I've started using OpenGL's built-in backface culling and it's giving a good performance boost. But is it really the fastest way to perform backface culling or is some sort of algorithm faster for this than OpenGL ??

Thanks in advance,

-Tobias Opfermann

GL backface culling - Feanor - Apr 19, 2002 03:48 PM

Because the back face culling process is pretty standard and is probably always hardware accelerated, there is no way you could out-perform it using a custom algorithm. I can't say that I know the complete details of OpenGL's algorithm, but I believe it creates a line between the first two verts in a triangle and checks which side the third vert is on (probably in the order submitted but I have no real idea). If you have front face set to CCW (standard IIRC), then if the third vert is on the right of the line defined by the first two, the triangle is facing backwards and so it isn't drawn. The algorithm is simple and I'm sure the hardware implementation is optimized as far as it can be.

You might want to ask yourself if you do a lot of setup of back-facing verts (though I can't see why), in which case you'd want to cull them yourself before even sending them to OpenGL. But since OpenGL is doing the textures and the lighting, you're safe to let it do bf culling too. You get extra benefits from OpenGL doing the culling if you're using either vertex arrays or display lists. If you culled yourself, I think you'd have to resubmit the array or rebuild the list every time a triangle was hidden or revealed. That sounds inefficient to me.


GL backface culling - OneSadCookie - Apr 19, 2002 03:50 PM

Generally a good guideline for this kind of thing is that if you can perform a test for more than N polygons at once, you should do that; otherwise just leave that test to OpenGL.

Unfortunately, N is highly dependent on both the test an the 3D card. For an ATI Rage128, N is almost always 1 Wink

Ultimately though, there's no substitute for trying several approaches and seeing which one is faster.

For the specific case of back-face culling, BSP trees give you the test for free...

GL backface culling - Tobi - Apr 19, 2002 11:32 PM

Thanks for the info.

I guess I'll stick to the GL Bf Culling. I'm using interleaved arrays for nearly everything, so doing an algorithm here seems to waste time.
Another thing like this:

I'm using an algorithm to do the clipping of all the objects on the 6 clipping planes. It's quite fast but I suppose OpenGL to be faster here as well. Can anyone confirm that?


GL backface culling - OneSadCookie - Apr 20, 2002 12:25 AM

Again, if you were going to cull individual polygons then yes, OpenGL would be faster, but because you can exploit the structure of the world, you can cull hundreds or thousands of polygons with a single test -- and that is worthwhile. Indeed, structures like Quadtrees, octtrees and BSP trees exist mainly to help with this task.