Closed andreasplesch closed 9 months ago
gl.bindTexture( gl.TEXTURE_2D, texture );
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
//gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image );
if ( properties.EMISSIVEMAPCHANNEL )
{
shader += "_emissiveColor = _emissiveColor * " + x3dom.shader.decodeGamma( properties, "texture2D(emissiveMap, vec2(texcoord2.x, 1.0-texcoord2.y)).rgb" ) + ";\n";
}
else
{
shader += "_emissiveColor = _emissiveColor * " + x3dom.shader.decodeGamma( properties, "texture2D(emissiveMap, vec2(texcoord.x, 1.0-texcoord.y)).rgb" ) + ";\n";
}
PR #1297
The glTF renderer fails this test:
https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/TextureEncodingTest
for emissive texture, and texture images files with embedded color profiles.
Emissive texture must be decoded from sRGB to linear and this can be done in the shader construction in DynamicShader.js where the EMISSIVEMAP is added.
The typical solution for ignoring embedded color profiles is to use createImageBitmap( imageElement, { colorSpaceConversion: "none" } ) which is not available for Safari at this point. Probably ImageTexture will need another field "colorSpaceConversion".