aboutsummaryrefslogtreecommitdiffstats
path: root/src/effects/shaders/distortionripple.frag
blob: e484ea4d60e7ec6b9c773d499c06ddf15e6ea676 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
VARYING vec2 center_vec;

void MAIN()
{
    float dist_to_center = length(center_vec) * 100.0 / radius;

    vec2 texc;
    if (dist_to_center > 1.0) {
        texc = INPUT_UV;
    } else {
        float r = radians(360.0) * (1.0 - dist_to_center);
        float distortion = sin(r * (100.0 - distortionWidth) + radians(distortionPhase));
        texc = INPUT_UV - (INPUT_UV - center) * distortion * distortionHeight / 800.0;
    }

    if (texc.x < 0.0 || texc.x > 1.0 || texc.y < 0.0 || texc.y > 1.0)
        FRAGCOLOR = vec4(0.0);
    else
        FRAGCOLOR = texture(INPUT, texc);
}