- Home /
Vertex color by face
Does Unity render Vertex color per face, instead of Vertex Color per... Vertex ?
Meaning, that a single vertex can have as many colors as shared faces.
For example, if I want all faces of a cube grey, and one face red, will only this face be red or will there be an automatic interpolation of color between the red vertices and the grey ones ?
Like this one, there is no interpolation between the yellow and the red faces :
Not that I know of, but you could use a 3*4 texture, even created procedurally.
I don't understand why the question got downvoted. Well, it's a very very basic and general thing that applies to any kind of engine, but for those that aren't familiar with it, it's valuable knowledge.
All those "my code doesn't work"-question don't get downvoted. This is actually a real question...
Wow, a lot of these guys are being oddly deter$$anonymous$$ed to say it isn't possible. Split vertex data has been around for-ev-er. For instance, I know that on .DAE model types (which are collada and old as snot), you can choose to record vertex color as 1 color OR multiple colors for each of it's faces. So please don't sit there and proudly proclaim something isn't possible because you know of just one way.
And it's uses are extremely broad. For instance, you can create the backside and the front side of a plane, give them the same uvs, but make the vertex color dark on one side. In other words, you have one texture, but on side looks shaded. This could be used to make a low poly rib cage with a shaded interior that uses textures efficiently.
Answer by Jessy · May 04, 2012 at 02:58 PM
Vertex color is always per-vertex (hence the name). The only reason it looks like it is per-face, is that you have the same color on all verts that make up the face. Interpolation happens, but any interpolation between values that are equal results in no change to the values. Where it looks like you have a hard edge, it's because you have multiple vertices in the same location. Modeling tools tend to hide this information from you, but I think that's stupid and leads to confusion.
This is true of all data stored in a mesh, except the triangle list. Faces are a result of interpolation of various data between vertices. You can't store anything in a polygon because polygons are made and remade by the GPU at runtime.
In 3ds $$anonymous$$ax, Vertex Color can be managed on a face basis, so that it doesn't interpolate. Too bad, that makes vertex color only usable for smooth objects, or square objects with split faces.
I understood what you said. I'm just saying that 3ds max can achieve this look (using vertices), which is just what I'm looking for. Whatever the underlying technique :)
Jessy is right, and I believe you did not fully grasp the implications of his explanation. With Unity, you can achieve both "looks": Your cube has 8 "real" vertices, but the Unity mesh would have 6*4=24 vertices, as well as 24 vertex colors, one for each vertex, so each face has its "own" vertices with its own vertex colors. Therefore you are free to choose whether these colors are the same for one face, or contain interpolated values of neighbouring faces. This approach is not optimal (since for the interpolated case you could make due with 8 distinct vertices (+colors) ins$$anonymous$$d of 24), but it is fully flexible. The same goes for the mesh normals, it's analogue to the vertex colors.
Ok, again: vertices can only be shared when they are 100% equal. A vertex consists of many data: the position, the color, the normal, uv coordinates maybe tangents / binormals and additional uv sets. If any of that data should be different for one triangle / "face", the vertex can't be shared anymore since it's not the same. This always results in duplicating the vertex.
Because a cube needs hard edges (different normal vector) it consists of 24 vertices ins$$anonymous$$d of 8. You need 4 vertices for each side 6*4 = 24.
$$anonymous$$odelling software is meant to create meshes. Sure they provide tools to manipulate the triangles / "faces" and vertices, but like Jessy said, some things are hidden to the user. When you change and of the above mentioned properties, the vertex needs to be splitted. 3DS $$anonymous$$ax may still show it as one vertex, but they aren't.