File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ void main()
14
14
mediump vec4 base = texture2D (inputImageTexture, textureCoordinate);
15
15
mediump vec4 overlay = texture2D (inputImageTexture2, textureCoordinate2);
16
16
17
- gl_FragColor = base * (overlay.a * (base / base.a ) + (2.0 * overlay * (1.0 - (base / base.a )))) + overlay * (1.0 - base.a ) + base * (1.0 - overlay.a );
17
+ lowp float alphaDivisor = base.a + step (base.a , 0.0 ); // Protect against a divide-by-zero blacking out things in the output
18
+ gl_FragColor = base * (overlay.a * (base / alphaDivisor) + (2.0 * overlay * (1.0 - (base / alphaDivisor)))) + overlay * (1.0 - base.a ) + base * (1.0 - overlay.a );
18
19
}
19
20
);
20
21
#else
@@ -31,7 +32,8 @@ void main()
31
32
vec4 base = texture2D (inputImageTexture, textureCoordinate);
32
33
vec4 overlay = texture2D (inputImageTexture2, textureCoordinate2);
33
34
34
- gl_FragColor = base * (overlay.a * (base / base.a ) + (2.0 * overlay * (1.0 - (base / base.a )))) + overlay * (1.0 - base.a ) + base * (1.0 - overlay.a );
35
+ float alphaDivisor = base.a + step (base.a , 0.0 ); // Protect against a divide-by-zero blacking out things in the output
36
+ gl_FragColor = base * (overlay.a * (base / alphaDivisor) + (2.0 * overlay * (1.0 - (base / alphaDivisor)))) + overlay * (1.0 - base.a ) + base * (1.0 - overlay.a );
35
37
}
36
38
);
37
39
#endif
You can’t perform that action at this time.
0 commit comments