obj2gltf icon indicating copy to clipboard operation
obj2gltf copied to clipboard

Vertex Colors Missing

Open ilkedemir opened this issue 8 years ago • 8 comments

I have an .obj file with vertex colors, and the colors are lost when converted to gltf/glb. I am able to view the colored .obj model in Meshlab and Preview.

I also tried to export in Collada, and the same problem occurs. Is there a way to preserve the vertex normals when converting to glb? Thanks.

colv7.obj.zip colv7.dae.zip colv7.gltf.zip

ilkedemir avatar Aug 19 '17 05:08 ilkedemir

The obj format does not support vertex colors. You may want to try COLLADA2GLTF if you haven't already.

lilleyse avatar Aug 20 '17 14:08 lilleyse

obj format does have a common extension to include vertex colors:

"A vertex can be specified in a line starting with the letter v. That is followed by (x,y,z[,w]) coordinates. W is optional and defaults to 1.0. Some applications support vertex colors, by putting red, green and blue values after x y and z. The color values range from 0 to 1."[1]

If this was a generic 3D application, I would say this is a trivial detail. But obj2gltf is indeed specific to obj conversion, thus I expect the application to support vertex colors.

I also tried COLLADA2GLTF, color info is not preserved in that conversion either, see this issue.

Can you please add this feature?

[1] https://en.wikipedia.org/wiki/Wavefront_.obj_file

ilkedemir avatar Aug 21 '17 18:08 ilkedemir

Thanks for the link @ilkedemir! I reopened this issue so that we have it on our radar but we don't have a timeframe on when support will be added. If anyone is interested in opening a PR to add this, we'll be happy for the contribution.

mramato avatar Aug 21 '17 20:08 mramato

I guess my knowledge of the obj format still has some holes.

Thanks for the info @ilkedemir, I don't see this being too hard to support.

lilleyse avatar Aug 23 '17 01:08 lilleyse

Requested again in https://github.com/AnalyticalGraphicsInc/obj2gltf/issues/186.

lilleyse avatar Mar 20 '19 15:03 lilleyse

I just encountered the same issue.

For anyone reading, in MeshLab with the .obj you can filters -> color creation and processing -> transfer color: vertex to face and then export back out to .obj and it will create the necessary .obj.mtl file.

hardreddata avatar Nov 24 '19 05:11 hardreddata

Thanks @RussellGrew , using MeshLab did the trick but does not correctly interpolates the colors.

lmoronil avatar May 18 '20 10:05 lmoronil

Requested again in https://github.com/CesiumGS/obj2gltf/issues/279

lilleyse avatar Jan 06 '23 15:01 lilleyse