Difference between revisions of "3D Fundamentals Tutorial 6"

From Chilipedia
Jump to: navigation, search
(Video)
(Video)
 
(3 intermediate revisions by the same user not shown)
Line 4: Line 4:
  
 
The tutorial video is on YouTube [https://www.youtube.com/watch?v=h_Aqol0oTs4 here].
 
The tutorial video is on YouTube [https://www.youtube.com/watch?v=h_Aqol0oTs4 here].
 
+
<div class="mw-collapsible mw-collapsed"><br />
 
* Recap of our problem: triangles are always drawn in the same order [https://youtu.be/h_Aqol0oTs4?t=0m20s 0:20]
 
* Recap of our problem: triangles are always drawn in the same order [https://youtu.be/h_Aqol0oTs4?t=0m20s 0:20]
 
* Solution: Back face culling [https://youtu.be/h_Aqol0oTs4?t=2m02s 2:02]
 
* Solution: Back face culling [https://youtu.be/h_Aqol0oTs4?t=2m02s 2:02]
 +
<div class="mw-collapsible-content">
 
:* Poor solution: painter's algoritm (sort the triangles back to front, draw front ones last)
 
:* 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
 
:* Better solution: never draw back facing triangles. For convex single objects front facing triangles will never overlap
 +
</div>
 
* Using a triangle's surface normal to determine its orientation [https://youtu.be/h_Aqol0oTs4?t=5m15s 5:15]
 
* Using a triangle's surface normal to determine its orientation [https://youtu.be/h_Aqol0oTs4?t=5m15s 5:15]
 +
<div class="mw-collapsible-content">
 
:* Just the z-component of the face normal is not good enough
 
:* 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)
 
:* 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)
 
:* (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
 
:* If their dot product is negative (opposide directions), the triangle's face is towards the focal point
 +
</div>
 +
* How to find the face normal: the cross product [https://youtu.be/h_Aqol0oTs4?t=9m51s 9:51]
 +
<div class="mw-collapsible-content">
 +
:* 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
 +
</div>
 +
* 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]
 +
<div class="mw-collapsible-content">
 +
:* The cross product operator in <code>Vec3</code>
 +
:* Using cull flags for the triangles [https://youtu.be/h_Aqol0oTs4?t=22m32s 22:32]
 +
</div>
 +
* 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]
 +
<div class="mw-collapsible-content">
 +
:* Use the left handed winding rule when constructing the triangle index list [https://youtu.be/h_Aqol0oTs4?t=27m08s 27:08]
 +
</div>
 +
* 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]
 +
<div class="mw-collapsible-content">
 +
:* 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
 +
</div>
 +
</div>
  
 
== Downloads ==
 
== Downloads ==

Latest revision as of 23:51, 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
  • 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.

See also