
uniform sampler2D g_color;
uniform float time;

layout (location = 0) out vec4 frag_color;


void main() {
    vec2 size = textureSize(g_color, 0).xy;
    float offset = size.y - mod(time * 2.0, size.y);
    float dist = distance(offset, gl_FragCoord.y);
    float shift = 1.0 - min(1.0, dist * 0.1);

    float r = texelFetch(g_color, ivec2(gl_FragCoord.xy) - ivec2(shift * 5.0, 0), 0).r;
    float g = texelFetch(g_color, ivec2(gl_FragCoord.xy) - ivec2(shift * 5.0, 0) - ivec2(-2, 0), 0).g;
    float b = texelFetch(g_color, ivec2(gl_FragCoord.xy) - ivec2(shift * 5.0, 0) - ivec2(2, 0), 0).b;
    vec3 col = vec3(r, g, b);

    col *= 0.7 + step(1.0, mod(gl_FragCoord.y, 5.0)) * 0.3;
    col *= 0.9 + step(1.0, mod(gl_FragCoord.y - 1.0, 5.0)) * 0.1;

    frag_color = vec4(col, 1.0);
}
