Search code examples
openglgraphicsrenderrasterculling

what is a clockwise face in openGL


In back face culling you may either use the face normals to see if the face is pointing away from the camera of you may do some technique with if the triangle is drawn clock wise or counter clock wise.

I am confused about this technique with the clockwise. It seems like with this method, the ordering of the vertex data that gets sent to the graphics card decides whether it is facing towards or away from the camera. I don't see how this makes sense because the camera can be looking in any direction, it's as if the vertex data would have to change based on the camera position and that is obviously not done on the CPU.

How can I understand this?


Solution

  • This is one triangle viewed from opposite sides:

    clockwise vs counterclockwise

    3 points in 3D space are defining a triangle. In addition, if those points are ordered (like here) they are also determining two sides (faces) of a triangle : clockwise and counter-clockwise (they are determined by the order clock put inside a face would point its vertices)

    In above example triangle is textured counter-clockwise

    Now imagine this triangle is an element of a dice:

    ccw textured box

    If you roll the dice (or rotate camera around it) our triangle from CCW becomes CW and we don't want it to be textured any more.

    This dice would be in fact built out of 12 such triangles and if we order them properly we will be texturing only 6 that are facing camera at a time.