Week 1 Day 2 - Introduction to Rendering
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.
Other Videos By Bill Kerney
2021-08-20 | Conditionals Part III |
2021-08-20 | Navmesh, Materials, Axis-Aligned Bounding Boxes |
2021-08-19 | Multiplayer Balance and UE4 Materials Pt. 2 |
2021-08-19 | The Optimizer, Bigints, Prime Generation, RSA Encryption, Cryptographic Hashing |
2021-08-18 | Conditionals Part II |
2021-08-17 | Line Rasterization |
2021-08-17 | Game Design Principles and UE4 Materials |
2021-08-17 | Powm, Modular Division, Espionage |
2021-08-16 | Strings, Conditionals, Logical Operators |
2021-08-13 | C++ Variables, Algebra, I/O |
2021-08-12 | Week 1 Day 2 - Introduction to Rendering |
2021-08-12 | Week 1 Day 2 - Game Design / Intro to UE4 |
2021-08-12 | Week 1 Day 2 - More Modulus |
2021-08-12 | Week 1 Day 2 - UNIX and Vim Basics; Hello World |
2021-08-10 | CSCI 26 Week 1 Day 1 Lecture |
2021-08-10 | IS50A Game Development Week 1 Day 1 |
2021-08-10 | IS50B Fall 2021 Week 1 Day 1 |
2021-08-09 | Week 1 Lecture 1 - Welcome to Computer Science |
2021-07-30 | Week 4 Day 5 - Presentations |
2021-07-29 | Week 4 Day 4 - Rotation and Lighting |
2021-07-29 | Bonus Lecture - Advice |