Specifying the Vertices of our First Triangle

Let’s make an equilateral triangle

Equilateral Triangle

Notes

Let’s make your first triangle special: an equilateral triangle, where each side of the triangle is the same length. Additionally, this triangle will live in the XY plane, which looks two-dimensional, but is really 3D just with the z-coordinate set to zero.

To determine each of the triangle’s vertices, we need to somehow compute their x- and y-coordinates. We might use some trigonometry, or a bit of algebra. If you’re math phobic, don’t fret! Unless you’re working with simple geometric shapes (like cubes, spheres, etc.), vertices will most often be provided to you in a model file of some nature.

We’re explicit about the vertices’ positions here to help demonstrate what’s processed in the shader, and some of the powerful mathematical operations you can get a GPU to do on your behalf.