If I've got 4 vertices which I render in this order:
2-3
|\|
0-1
using GL_TRIANGLE_STRIP
and then I enable back-face culling with the front face defined as CCW, then would the bottom-left triangle be facing me and the other one not? If so, what's the most efficient way of rendering a square so that both faces are visible? Do I have to use GL_TRIANGLES
and pass down 6 vertices instead of 4?
In computer graphics, back-face culling determines whether a polygon of a graphical object is drawn. It is a step in the graphical pipeline that tests whether the points in the polygon appear in clockwise or counter-clockwise order when projected onto the screen.
To enable face culling we only have to enable OpenGL's GL_CULL_FACE option: glEnable (GL_CULL_FACE); From this point on, all the faces that are not front-faces are discarded (try flying inside the cube to see that all inner faces are indeed discarded).
Face culling allows non-visible triangles of closed surfaces to be removed before expensive Rasterization and Fragment Shader operations. To activate face culling, GL_CULL_FACE must first be enabled with glEnable. By default, face culling is disabled.
When making custom block models, you can run into an issue known as culling. This is when the adjacent blocks have their face(s) hidden to save on render time. If your block model does not take up the full 16x16 area, you will see holes in adjacent blocks.
The strip primitive does the right thing with respect to backface culling. You can think of the tris' winding order as being managed so that the order is consistent for each triangle in the strip - e.g. you can think of the GPU rendering (0,1,2), (2,1,3) ...
All triangles in triangle strip maintain same direction/winding order. They don't flip one after another. So either both triangles will be towards you or away from you (assuming your primitive is flat square shape (that is convex and doesn't intersect itself) where all vertices belong to same plane).
P.S. You know, you COULD render trianglestrip primitive in OpenGL application with culling enabled and see for yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With