openglculling

Should I always use GL_CULL_FACE?


Should I always be using this method when rendering? Does it slow down much on bad graphics cards?

If the end result will not have many culled faces, should I even be using this method then?


Solution

  • If all your models are defined correctly (convex, with consistent vertex winding), culling will never hurt performance, and will nearly always help performance.

    Imagine you are rendering a cube, with culling disabled. The faces on the back (far side) of the cube get rendered facing away from you, and whatever back face material attributes you've chosen get applied. Then the faces on the front of the cube get rendered: since the back faces that were just rendered are the inside of the cube, they are 100% occluded by the front faces.

    If the cube was oriented differently, the front faces might be rasterized first, but the back faces will still be processed and then the fragments rejected by the z buffer.

    Net result: you rasterized 2x as many fragments as necessary. This gets to be a big deal with large numbers of polygons or complex pixel shaders. Face culling allows you to completely avoid rasterizing faces that you know won't show up.

    If you have a character model with ~100,000 polygons, face culling halves the amount of work the pixel hardware has to do every frame. This is a big savings if you have big surface shaders.

    If you're working with small models and no shaders, culling really doesn't matter these days. But it's good practice to enable anyway.