3D Fundamentals Tutorial 6
From Chilipedia
Get rid of those dirty back-facers, we don't serve their kind here. Also, learn the new sex move that is taking New England by storm: the Bridgeport Shocker.
Video
The tutorial video is on YouTube here.
- Recap of our problem: triangles are always drawn in the same order 0:20
- Solution: Back face culling 2:02
- Poor solution: painter's algoritm (sort the triangles back to front, draw front ones last)
- Better solution: never draw back facing triangles. For convex single objects front facing triangles will never overlap
- Using a triangle's surface normal to determine its orientation 5:15
- Just the z-component of the face normal is not good enough
- Correct approach: take the viewing vector (v1) and the face normal direction (v2)
- (viewing vector: vector from focal point to any point on the triangle in world space)
- If their dot product is negative (opposide directions), the triangle's face is towards the focal point
Downloads
The GitHub repository for the tutorial code is here.