Bug 165297

Summary: PNG textures with zero alpha channel have wrong rgb colors when reading them in a shader
Product: WebKit Reporter: ivan <nederland074>
Component: WebGLAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: alex, dino, eric.carlson, felixmariotto, gman, jonlee, justin_fan, mail, michael.herzog, sfranci, supermoos, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 10   
Hardware: iPhone / iPad   
OS: iOS 10   
Attachments:
Description Flags
Test archive (HTML + PNGs) none

Description ivan 2016-12-02 01:40:08 PST
Created attachment 295932 [details]
Test archive (HTML + PNGs)

When reading a texture created from a PNG image in a shader (via the texture2D() call) the rgb color depends on the alpha value. If the alpha is zero, when the rgb color is completely black regardless of what's actually stored in texture channels. If the alpha is non-zero (even if it's 1/255) the rgb color is correct. This behavior makes it more difficult to use a texture as a storage for independent data in a form of packed together rgba channels.

This issue doesn't occur for a similar texture, that's created from a uint8array array buffer, so it's probably related to PNG images. Also, this issue doesn't occur in Safari/Chrome/Firefox under macOS 10.10.3.

In the attachment there is the example that demonstrates rendering the RGB color from a red texture which alpha channel filled with 1/255 value (working_image.png) and with zero value (not_working_image.png). Both should be red, but the latter is black on iPad.
Comment 1 Dean Jackson 2016-12-12 16:59:10 PST
<rdar://problem/29630830>
Comment 2 Gregg Tavares 2019-04-01 16:22:58 PDT
2 years and this bug is still not fixed?

iOS safari does not pass the conformance tests

https://www.khronos.org/registry/webgl/sdk/tests/conformance/textures/misc/gl-teximage.html?webglVersion=1&quiet=0&quick=1
Comment 3 Michael Herzog 2019-04-02 01:32:43 PDT
This issue was also reported at the three.js forum (https://discourse.threejs.org/t/texture-rgb-values-are-zero-when-alpha-is-zero-on-ios/6840). We've added a fiddle that should work as an additional test case. Normally, the entire plane should be red. On iOS Safari and Chrome, the bottom left part of the plane is black. https://jsfiddle.net/vyzc2sgj/1/
Comment 4 Felix Mariotto 2021-08-04 01:02:47 PDT
5 years later, this issue is still not fixed.