Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opengl Depth buffer and Culling

Tags:

opengl

culling

Whats's the difference between use back face culling and a buffer of depth in OpenGL?

like image 972
Lucas Avatar asked Dec 04 '22 13:12

Lucas


1 Answers

Backface culling is when OpenGL determines which faces are facing away from the viewer and are therefore unseen. Think of a cube. No matter how your rotate the cube, 3 faces will always be invisible. Figure out which faces these are, remove them from the list of polygons to be drawn and you just halved your drawing list.

Depth buffering is fairly simple. For every pixel of every polygon drawn, compare it's z value to the z buffer. if it's less than the value in the z buffer set the z buffer value as the new z buffer value. If not, discard the pixel. Depth buffering gives very good results but can be fairly slow as each and every pixel requires a value lookup.

In reality there is nothing similar between these two methods and they are often both used. Given a cube you can first cut out half the polygons using culling then draw them using z buffering.

Culling can cut down on the polygons rendered, but it's not a sorting algorithm. That's what Z buffering is.

like image 141
Timothy Baldridge Avatar answered Jan 31 '23 17:01

Timothy Baldridge