3D Fundamentals Tutorial 6

From Chilipedia
Revision as of 23:43, 11 May 2020 by R vdw (Talk | contribs) (Video)

Jump to: navigation, search

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
  • How to find the face normal: the cross product 9:51
  • Comparison of concepts of dot product and cross product
  • v1 x v2 yields a perpendicular vector (following left hand rule in our system) with length l = area of the parallelogram spanned by v1 and v2
  • The math equation for the cross product 16:13
  • Getting the face normal vector of our triangles 19:26
  • Implementing these concepts in our code 21:04
  • The cross product operator in Vec3
  • Using cull flags for the triangles 22:32
  • Culling needs to be performed before the transformation to screen space 24:33
  • The order of the vertices (i.e. the index lists for triangles) matters 26:04
  • Use the left handed winding rule when constructing the triangle index list 27:08
  • Introduction of Scene definitions and the SolidCubeClass

Downloads

The GitHub repository for the tutorial code is here.

See also