Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
4.7.4
-
None
-
Windows, Ubuntu, Various graphics cards
Description
The blending formula of the output of a fragment shader on the scene seems to be incorrect.
If S is the output of the fragment shader, and D the surface to be blended in, the blending formula seems to be vec3(S.rgb*0.5 +D.rgb*0.5) * (1-S.a) + vec3(S.rgb) * S.a, instead of vec3(D.rgb) * (1-S.a) + vec3(S.rgb) * S.a. That means, that when the output of a fragment shader is transparent (aka alpha component of 0), the RBG components are added to the one of the destination (halved), instead of being ignored.
Notice that when the output of a fragment shader is opaque, or if its RBG component is 0 when its alpha is 0, there are no problems, which may make the problem hard to detect.
It can be tested simply by doing:
gl_FragColor = vec4(1.0f, 0.0f, 0.0f, 0.0f);
If you have a black background, the zone covered by the shader will be between red and black, if you have a background with a red component of 255 (like a white background), it will be unchanged.
The fragment shader in the uploaded zip test case is supposed to blend red onto the source image where it's not transparent, and keep other pixels transparent.