Week 1 Day 2 - Introduction to Rendering

Channel:
Subscribers:
2,640
Published on ● Video Link: https://www.youtube.com/watch?v=YZWX5SVlmiE



Duration: 1:11:55
43 views
1


Today we started our conversation about what is going on behind the scenes in a 3D engine. A 3D Engine's job is to take a bunch of triangles in the world and draw them on the screen as quickly and accurately as possible.


We talked about:
1) Frustrums - they are like pyramids with the top chopped off. There is a "view frustrum" which controls what objects are in view of the camera. Everything outside it gets culled.
2) Culling - culling means that a triangle won't be drawn. We cull as many triangles as we can as early as we can to keep the frame rate up. If a triangle is outside the view frustrum, or if a triangle is backwards (the points on a triangle are either clockwise or counterclockwise meaning forwards/backwards or vice-versa), or if a triangle is completely occluded (blocked from view) and the engine can know this (for example if you're in a room and it's in another room with no line of sight) then the triangle is culled and not processed further.
3) Projection - every 3D point in the view frustum corresponds to a 2D location on the screen - some row and column. There is a "projection matrix" associated with each camera that does the linear algebra to transform an {x,y,z} location in the world to a {row,col,depth} on the screen. Depth being how far away from the camera it is.

4) Filling - For every pixel (fragment, technically) within a triangle, it is drawn to a screen buffer / framebuffer which is a 2D array that holds the color values at every point on the screen. So for a triangle that is all pure red, all of the points in that triangle are filled in red.
5) Depth testing - a "z buffer" is usually used to handle conflicts when two triangles draw to the same pixel in the frame buffer. Whichever pixel is closer to the camera (has a smaller z value) gets drawn and the other is discarded.


You can actually use your knowledge of the math of 3D games to make simple renderers rather quickly. It's fun and a great way to stretch your programming chops.







Tags:
is50b
rendering