Difference between revisions of "3D Fundamentals Tutorial 6"
From Chilipedia
(→Video) |
(→Video) |
||
Line 25: | Line 25: | ||
* The order of the vertices (i.e. the index lists for triangles) matters [https://youtu.be/h_Aqol0oTs4?t=26m04s 26:04] | * 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] | :* Use the left handed winding rule when constructing the triangle index list [https://youtu.be/h_Aqol0oTs4?t=27m08s 27:08] | ||
− | * Introduction of | + | * Introduction of the base class <code>Scene.h</code> for scene definitions its derived classes [https://youtu.be/h_Aqol0oTs4?t=28m50s 28:50] |
+ | * Remaining issues: concave shapes, triangle intersections, occlusion [https://youtu.be/h_Aqol0oTs4?t=31m10s 31:10] | ||
+ | :* You can't easily sort this with sorting (although sorting has its place in 3d graphics) | ||
+ | :* We will come back to these issues later in the series | ||
== Downloads == | == Downloads == |
Revision as of 23:46, 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 the base class
Scene.h
for scene definitions its derived classes 28:50 - Remaining issues: concave shapes, triangle intersections, occlusion 31:10
- You can't easily sort this with sorting (although sorting has its place in 3d graphics)
- We will come back to these issues later in the series
Downloads
The GitHub repository for the tutorial code is here.