GLTF specifies that all colors in gltf json should be represented in linear space.
OBJ files have their colors defined in sRGB space.
obj2gltf now takes colors directly from OBJ and puts them in GLTF, but there should be conversion from sRGB to linear rgb colorspace.
Note that colors in textures are sRGB both in obj and gltf, only base color (diffuse) and emissive colors should be converted.
See this linked issue in Blender: https://projects.blender.org/blender/blender-addons/issues/102905#issuecomment-11438
and the corresponding discussion in gltf spec repository: KhronosGroup/glTF#1609 (comment)
The corresponding locations in code where the change should be made:
|
material.diffuseColor = [ |
|
parseFloat(values[0]), |
|
parseFloat(values[1]), |
|
parseFloat(values[2]), |
|
1.0, |
|
]; |
|
material.emissiveColor = [ |
|
parseFloat(values[0]), |
|
parseFloat(values[1]), |
|
parseFloat(values[2]), |
|
1.0, |
|
]; |
EDIT:
Let me also link Bevy engine PR that also fixed this: bevyengine/bevy#6828
GLTF specifies that all colors in gltf json should be represented in linear space.
OBJ files have their colors defined in sRGB space.
obj2gltfnow takes colors directly from OBJ and puts them in GLTF, but there should be conversion from sRGB to linear rgb colorspace.Note that colors in textures are sRGB both in obj and gltf, only base color (diffuse) and emissive colors should be converted.
See this linked issue in Blender: https://projects.blender.org/blender/blender-addons/issues/102905#issuecomment-11438
and the corresponding discussion in gltf spec repository: KhronosGroup/glTF#1609 (comment)
The corresponding locations in code where the change should be made:
obj2gltf/lib/loadMtl.js
Lines 139 to 144 in ce0c36e
obj2gltf/lib/loadMtl.js
Lines 131 to 136 in ce0c36e
EDIT:
Let me also link Bevy engine PR that also fixed this: bevyengine/bevy#6828