Vertex Colors Missing
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.
The obj format does not support vertex colors. You may want to try COLLADA2GLTF if you haven't already.
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
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.
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.
Requested again in https://github.com/AnalyticalGraphicsInc/obj2gltf/issues/186.
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.
Thanks @RussellGrew , using MeshLab did the trick but does not correctly interpolates the colors.
Requested again in https://github.com/CesiumGS/obj2gltf/issues/279