I'm implementing a model class which loads OBJ and MTL files, and ran into an issue or question with face materials.
Consider the following example: It's a cube with 5 sides Gray and 1 side Green.
mtllib Materials.mtl
o Cube
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
v 1.000000 1.000000 -1.000000
v 1.000000 1.000000 1.000000
usemtl Green
f 7 8 4 3
usemtl Gray
f 5 8 2 1
f 6 7 3 2
f 8 5 1 4
f 1 2 3 4
f 8 7 6 5
The OBJ file obviously shares same vertices for adjacent faces even if the faces get different materials.
When drawing such a cube with OpenGL however, I would need to duplicate the vertices of the adjacent faces with different materials, since every vertex specifies the color it has - and I have two different colors for the same vertices here, depending on the face and the different material it has. If I wouldn't do that, the adjacent faces would smooth over to the different materials.
First: Did I get this correctly or am I missing an OpenGL "feature" here which lets me "specify" the color of a whole triangle / face rather than a single vertex?
Second: If not, is there an easier way to keep track of the faces materials and duplicating the adjacent vertices if they get different materials? What would be the easiest way to implement different materials on one object?