A Mesh with Color

Now let's add color. Let's make the roof red and walls yellow.

Ideally we would associate color with the triangles. We would add $r$, $g$, and $b$ values to each row of the triangle table.

Unfortunately, the design of the GL requires that we instead associate attributes, such as color, with the vertices.

So, each vertex in the table will now have 6 components, $x$, $y$, and $z$, plus $r$, $g$ and $b$.

$i$$x$$y$$z$$r$$g$$b$
0 0.01.0 0.5 ? ? ?
1−0.50.5 0.5 ? ? ?
2−0.50.0 0.51.01.00.9
3 0.50.0 0.51.01.00.9
4 0.50.5 0.5 ? ? ?
5 0.01.0−0.5 ? ? ?
6−0.50.5−0.5 ? ? ?
7−0.50.0−0.51.01.00.9
8 0.50.0−0.51.01.00.9
9 0.50.5−0.5 ? ? ?

But there's a problem. Vertex 4, for example, has two colors.