Depth and Blending
Cull Face Winding
Face culling removes back-facing triangles so only geometry with the configured winding remains visible.
Program
WebGL classifies triangle orientation from vertex winding. Culling can skip back faces before fragment shading.
cull_face_winding.html
Visuals: generated teaching cards from captured state
- state written by this keyframe
1<canvas id="stage" width="360" height="210"></canvas>
2<script>
3 gl.enable(gl.CULL_FACE);
4 gl.frontFace(gl.CCW);
5 gl.cullFace(gl.BACK);
6 gl.drawArrays(gl.TRIANGLES, 0, 6);
7</script>Enable face culling
kf: 1event 0kind: lifecycleEnable face culling.
3gl.enable→ enabled(gl.CULL_FACE);
Culling happens before fragments are shaded. State after this keyframedisabled → enabledcullingTreat counter-clockwise winding as front-facing
kf: 2event 1kind: lifecycleTreat counter-clockwise winding as front-facing.
4gl.frontFace→ CCW(gl.CCW);
Vertex order determines the visible side of a triangle. State after this keyframedefault → CCWfront faceCull back-facing triangles
kf: 3event 2kind: lifecycleCull back-facing triangles.
5gl.cullFace→ back(gl.BACK);
Back-face culling is common for closed 3D meshes. State after this keyframenone → backculled faceDraw one CCW and one clockwise triangle
kf: 4event 3kind: lifecycleDraw one CCW and one clockwise triangle.
6gl.drawArrays→ only CCW triangle(gl.TRIANGLES, 0, 6);
The clockwise triangle is culled before rasterization. State after this keyframeclear color → only CCW trianglepixels
winding
Winding is the order of triangle vertices as seen on screen.
face culling
Face culling discards front or back faces based on winding classification.