Difference between revisions of "3D Fundamentals Tutorial 6"
From Chilipedia
(→Video) |
(→Video) |
||
Line 15: | Line 15: | ||
:* If their dot product is negative (opposide directions), the triangle's face is towards the focal point | :* 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 [https://youtu.be/h_Aqol0oTs4?t=9m51s 9:51] | * How to find the face normal: the cross product [https://youtu.be/h_Aqol0oTs4?t=9m51s 9:51] | ||
− | :* Comparison of concepts of | + | :* 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 | :* 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 [https://youtu.be/h_Aqol0oTs4?t=16m13s 16:13] | ||
+ | * Getting the face normal vector of our triangles [https://youtu.be/h_Aqol0oTs4?t=19m26s 19:26] | ||
+ | * Implementing these concepts in our code [https://youtu.be/h_Aqol0oTs4?t=21m04s 21:04] | ||
+ | :* The cross product operator in <code>Vec3</code> | ||
+ | :* Using cull flags for the triangles [https://youtu.be/h_Aqol0oTs4?t=22m32s 22:32] | ||
+ | * Culling needs to be performed before the transformation to screen space [https://youtu.be/h_Aqol0oTs4?t=24m33s 24:33] | ||
+ | * The order of the vertices (i.e. the index lists for triangles) matters [https://youtu.be/h_Aqol0oTs4?t=26m04s 26:04] | ||
+ | :* Use the left handed winding rule when constructing the triangle index list [https://youtu.be/h_Aqol0oTs4?t=27m08s 27:08] | ||
+ | * Introduction of Scene definitions and the <code>SolidCubeClass | ||
== Downloads == | == Downloads == |
Revision as of 23:43, 11 May 2020
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
- The cross product operator in
- 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.