CesiumGS / obj2gltf

Convert OBJ assets to glTF
Apache License 2.0
1.71k stars 307 forks source link

Vertex Colors Missing #102

Open ilkedemir opened 7 years ago

ilkedemir commented 7 years ago

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

lilleyse commented 7 years ago

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

ilkedemir commented 7 years ago

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

mramato commented 7 years ago

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.

lilleyse commented 7 years ago

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 commented 5 years ago

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

hardreddata commented 4 years ago

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.

lmoronil commented 4 years ago

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

lilleyse commented 1 year ago

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