1#define CRT_MASK
2
3varying vec2 varTex0;
4
5void main() {
6    lowp vec4 color = texture2D(UNI_Tex0, varTex0);
7    
8    vec2 powers = pow(abs((gl_FragCoord.xy / vec2(UNI_width, UNI_height)) - 0.5), vec2(2.0));
9    float gradient = smoothstep(UNI_size - UNI_feather, UNI_size + UNI_feather,
10            powers.x + powers.y);
11
12    color = vec4(mix(color.rgb, vec3(0.0), gradient), 1.0);
13
14#ifdef CRT_MASK
15    float vShift = gl_FragCoord.y;
16    if (mod(gl_FragCoord.x, 6.0) >= 3.0) {
17        vShift += 2.0;
18    }
19
20    lowp vec3 r = vec3(0.95, 0.0, 0.2);
21    lowp vec3 g = vec3(0.2, 0.95, 0.0);
22    lowp vec3 b = vec3(0.0, 0.2, 0.95);
23    int channel = int(floor(mod(gl_FragCoord.x, 3.0)));
24    lowp vec4 crt = vec4(r[channel], g[channel], b[channel], 1.0);
25    crt *= clamp(floor(mod(vShift, 4.0)), 0.0, 1.0);
26    
27    color = (crt * color * 1.25) + 0.05;
28#endif
29
30    gl_FragColor = color;
31}
32