There is a limited way to color the faces of your glDrawElements mesh by triangle (as shown in Blender) instead of by vertex (as shown in the lower image):
- Pass the position attribute as a vec4 instead of vec3, use a stride of 4 for float[] koordinates.
- Set the fourth (w) value of each vertex to a "dictionary" value corresponding to each color. E.g. 0.0f = yellow, 0.5f = red, 1.0f = white. The middle value will be the "default."
- In the vertex shader, pass the w value to the frag shader as a varying, then reset the w to 1.0 before performing matrix transformations like perspective etc. Use < or > 0.5f due to interpolation.
- In the fragment shader, compare the varying to fixed values and set fragment color to predefined values before performing shading adjustments.
You can use a little more creativity (binary masks?) to index more colors but each strategy is limited to using a single w for the color (without being able to use a mat3 as an attribute in glDrawElements in ES2.0). You can also pass float[] colors (only one entry per color) as a uniform vec3 array and read color values from there.