Sunday, March 29, 2009

On the storage of Color in meshes

A very short post to clarify a bit the ways in which people can store color (and other) information on a mesh. AFAIK there are mostly three ways to keep color:
  • Per-vertex: each vertex stores a color. A triangular face can have vertexes of different color and inside a triangle the color is linearly interpolated. Color is smooth across the surface.
  • Per face: each face has a distinct color. You can easily see the discontinuity of colors among the faces (no interpolation is usually done.
  • As texture: the most general way that is reasonably decoupled from the mesh itself. You only need a good parametrization.
In MeshLab most of the algorithms (painting, color processing etc.) manage per-vertex color, but a few conversion tools are provided.
  • per-vert -> per -face
  • per-face -> per-vert
  • texture -> per-vert
A per-vert -> texture is strikingly missing :). To be added in the very near future. Obviously assuming the previous existence of a parametrization...
A fourth technique could be mentioned, keeping stuff per wedge, i.e. for each corner of the face we can store different colors (or other attributes), but this approach is rather unused (it can be simulated by duplicating vertices).
Below a few images showing the difference between the three modes on a small (40k tri) mesh; respectively: no color (to give you an idea of mesh density), color by texture, per vertex color, per face color.


castano said...

I've looked at several mesh libraries in the past, and one of the reasons why I usually end up writing my own is because they lack the ability to represent per wedge attributes.

Being able to have sharp color and normal discontinuities is important, but being able to have multiple texture coordinates per vertex is an absolute requirement.

I've seen that some people work around that problem by storing these attributes on the half-edges instead of of the vertices. I think that solution is OK, but duplicates a lot of data.

Another simple option is to duplicate vertices that need to have different attributes. That works as well, but then some connectivity information is lost and to recover it you have to drop the discontinuous attributes.

My preferred solution is to extend the half-edge structure to support colocal vertices. These vertices have the same position, but different attributes and are linked together, so you that given one you can visit the others. Half edges point to the corresponding colocal vertex, but one ring traversals are not influenced by that and treat the mesh as if it were closed.

Does MeshLab handle that differently? If not, then what approach do you recommend? what's the cleanest way of doing that in MeshLab?

ALoopingIcon said...

I have never found the "perfect" solution for storing color on a mesh. Every time we choose according to project needs and constraints.

In practice for very dense meshes (tens of millions of vertices) we go for vertex-color, and for more standard meshes (hundred of thousands of vertices) we go for texturing. Per-face color is rather unused for us.

MeshLab could support per-wedge color, (simply because the underlying mesh library, support per-wedge attributes) but in practice we do not have a lot of algorithms for processing/creating this kind of data (with the notable exception of per wedge normals).

are you this castano?

castano said...

Yes, that's me. I find wedge attributes most important for texture coordinates. I was not aware VCG supported them, I should have a closer look!

Anonymous said...

I know there are three for colors but it depends on we seeing things for example when I take generic viagra I can seeing a lot of colors around ne I don't know why, I think it's because my pupils get so expanded or something like that.

sasha said...

How I can create a mesh with per wedge color?