File tree Expand file tree Collapse file tree
src/renderer/webgl/shaders/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,15 +4,36 @@ precision mediump float;
44
55uniform sampler2D uMainSampler;
66uniform float uColorMatrix[20 ];
7+ uniform float uAlpha;
78
89varying vec2 outTexCoord;
910
1011void main ()
1112{
1213 vec4 c = texture2D (uMainSampler, outTexCoord);
1314
14- gl_FragColor .r = uColorMatrix[0 ] * c.r + uColorMatrix[1 ] * c.g + uColorMatrix[2 ] * c.b + uColorMatrix[4 ];
15- gl_FragColor .g = uColorMatrix[5 ] * c.r + uColorMatrix[6 ] * c.g + uColorMatrix[7 ] * c.b + uColorMatrix[9 ];
16- gl_FragColor .b = uColorMatrix[10 ] * c.r + uColorMatrix[11 ] * c.g + uColorMatrix[12 ] * c.b + uColorMatrix[14 ];
17- gl_FragColor .a = c.a;
15+ if (uAlpha == 0.0 )
16+ {
17+ gl_FragColor = c;
18+
19+ return ;
20+ }
21+
22+ if (c.a > 0.0 )
23+ {
24+ c.rgb /= c.a;
25+ }
26+
27+ vec4 result;
28+
29+ result.r = (uColorMatrix[0 ] * c.r) + (uColorMatrix[1 ] * c.g) + (uColorMatrix[2 ] * c.b) + (uColorMatrix[3 ] * c.a) + uColorMatrix[4 ];
30+ result.g = (uColorMatrix[5 ] * c.r) + (uColorMatrix[6 ] * c.g) + (uColorMatrix[7 ] * c.b) + (uColorMatrix[8 ] * c.a) + uColorMatrix[9 ];
31+ result.b = (uColorMatrix[10 ] * c.r) + (uColorMatrix[11 ] * c.g) + (uColorMatrix[12 ] * c.b) + (uColorMatrix[13 ] * c.a) + uColorMatrix[14 ];
32+ result.a = (uColorMatrix[15 ] * c.r) + (uColorMatrix[16 ] * c.g) + (uColorMatrix[17 ] * c.b) + (uColorMatrix[18 ] * c.a) + uColorMatrix[19 ];
33+
34+ vec3 rgb = mix (c.rgb, result.rgb, uAlpha);
35+
36+ rgb *= result.a;
37+
38+ gl_FragColor = vec4 (rgb, result.a);
1839}
You can’t perform that action at this time.
0 commit comments