- Home /
Can you specify the color of a triangle that you created in a mesh?
What I mean is if I create a mesh and I have the list of triangles is there a method or some easy way to essentially make it so that I can write triangle[x].color=blue; (or any color)
The reason why I want to know is because I am attempting to make a hexagon grid based game and it is really easy to figure out a which triangle belongs to which hexagon, so for prototyping it would be nice if I could specify the colors of a triangle.
Thanks ahead of time.
I don't know of any way to do this directly. If the triangle does not share vertices with other triangles, you can set the vertex colors for that triangle and use a shader that supports vertex colors. Or for example, if each hexagon had its own set of vertices and did not share, you could set the vertex colors for all the vertices in the hexagon to set a hexagon to a specific color.
As an alternate to vertex colors, you could create a texture atlas of different colors and set the uv coordinates of each vertex. The mesh would get its color from the texture, but it suffers from the same problem as vertex colors...you cannot share vertices.