aboutsummaryrefslogtreecommitdiffstats
path: root/src/effects/shaders/edgedetect.frag
blob: 2b9aaf60559f38bff13b241d50c6ed015f4ad429 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
VARYING vec4 TexCoordBLL;
VARYING vec4 TexCoordTLT;
VARYING vec4 TexCoordTRR;
VARYING vec4 TexCoordBRB;

void MAIN()
{
    vec4 centerTap = texture(INPUT, INPUT_UV);
    vec4 edgeTap = texture(INPUT, TexCoordBLL.xy)
            + texture(INPUT, TexCoordBLL.zw)
            + texture(INPUT, TexCoordTLT.xy)
            + texture(INPUT, TexCoordTLT.zw)
            + texture(INPUT, TexCoordTRR.xy)
            + texture(INPUT, TexCoordTRR.zw)
            + texture(INPUT, TexCoordBRB.xy)
            + texture(INPUT, TexCoordBRB.zw);
    vec3 edgeDetect = 8.0 * (centerTap.rgb - (0.125 * edgeTap.rgb));
    edgeDetect = clamp(edgeDetect, 0.0, centerTap.a);

    FRAGCOLOR = vec4(mix(centerTap.rgb, edgeDetect, edgeStrength), centerTap.a);
}