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
Keywords: InRadar
Depends on:
Reported: 2016-12-02 01:40 PST by ivan
Modified: 2021-08-04 01:02 PDT (History)
12 users (show)

See Also:

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
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

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.