Bug 165297 - PNG textures with zero alpha channel have wrong rgb colors when reading them in a shader
Summary: PNG textures with zero alpha channel have wrong rgb colors when reading them ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: Safari 10
Hardware: iPhone / iPad iOS 10
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-12-02 01:40 PST by ivan
Modified: 2019-04-02 01:32 PDT (History)
8 users (show)

See Also:


Attachments
Test archive (HTML + PNGs) (10.00 KB, application/x-tar)
2016-12-02 01:40 PST, ivan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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/