OBJ loader vertex color parsing issue
chrisgervang opened this issue · comments
I noticed the mesh vertex colors aren't parsed by loaders.gl
Blender 3.2+ has added support for exporting OBJ files with vertex colors, so now textures can be baked into a mesh for applications where this is preferred.
I have a suspicion this bit of the parser is causing the issue:
Looking at three.js, it assumes a data length of 7 or more means there are vertex colors to be parsed.
https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/OBJLoader.js#L532
Is there a reason loaders opted to look for 8 elements before parsing color?
cc: @ibgreen
Hey @belom88 I pushed the fix to 3.4-release. Could you please cut a patch?
Now that colors are parsing I'm able to see issues today in how colors are assigned to faces. I haven't not isolated the cause - I think setting up a OBJ debugger in our examples would make it easier to work on.
Not sure what problems you are seeing, but:
- if you want a face to be colored with a single color, you need all vertices for that face to be colored with that color.
- This typically means that the geometry cannot share vertices / corners, if you have different colors per face.
- I would assume whatever tool generates these OBJ files (blender) would deduplicate the vertices before saving.
Another possible issue would be if color array has 3 elements per color (RGB) and the layer expects 4 (RGBA) or vice versa. Perhaps an option to pad alpha values may be needed.
Close due to inactivity