Week 3 Day 5 - Coloring and Triangle Rasterization

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



Duration: 1:06:00
38 views
1


Today we started with our line rasterizer and made the following changes:


1) We switched to a vertex buffer style of holding the data for every point we will be connecting with lines, so we don't have duplicate points all over the place. Each point will only appear once in the vertex buffer, but can be shared by different triangles and line segments. The line segments and triangles will just hold the index in the vertex buffer.


2) Adding a color to each point. We hold colors as a trio of unsigned 8-bit values. The first value is red, then green, then blue. (0,0,0) is black, (255,255,255) is white, (255,0,255) is purple, and so forth.


We then started a move from line rasterization to triangle rasterization. We finished for the day with an algorithm that identifies all spots inside a triangle but could be obviously much better. But it works for now.


A big point for today is the notion of Barycentric coordinates in a triangle, which is a way of measuring how far a point is away from the three corners of the triangle, which is useful if you're going to be interpolating values like colors across the triangle.


We also briefly talked about Lerping, which comes up a lot in computational geometry and gaming. If you have an air conditioner on your car, and the minimum temperature is 60F and the max is 90F, then as you turn the knob you will see it smoothly set the temperature between 60 and 90 as the knob (which we'll call alpha) moves from 0 (left) to 1 (right).


To Lerp between two values A and B with an alpha ranging from 0 to 1, looks like this:
A*(1-alpha) + B*(alpha). So when alpha is 0, you get A. When alpha is 1, you get B. When it's .5, you get halfway between A and B, and so forth.