Sarah Yoo

Boosting Performance with Back-Face Culling

The last step of optimization is face culling. Face culling skips drawing faces that aren't visible to the camera (e.g. the back face of block surfaces). This reduces the number of draw calls and therefore improves performance.

OpenGL allows to determine which side of a face is front by the winding order of vertices, either clockwise or counter-clockwise.

The image shows two triangles whose its vertices are wound in different orders: winding order

In my engine, all front faces are wound in clockwise order, so I configure OpenGL like this:

glEnable(GL_CULL_FACE);
glFrontFace(GL_CW);

This tells OpenGL to cull back faces wound in the counter-clockwise order.

Now the back face of surface is invisible:

Backface Culling

Both the back and front sides of water surface are rendered because its vertices are wound in the clockwise, meaning water has only front faces.

Handling Transparent and Double-Sided Objects

One of the problems that can arise by using back-face culling is that it culls the back faces of objects that want to be visible from all sides, such as water or flowers.

As shown above, the solution is to manually add and wind the faces that need to remain visible in the same winding order as the front faces, which in my case, clockwise.