precision highp float;

uniform vec2 resolution;
uniform float time;
uniform vec2 mouse;
uniform sampler2D backbuffer;

highp float rand(vec2 co){
    highp float a = 12.9898;
    highp float b = 78.233;
    highp float c = 43758.5453;
    highp float dt= dot(co.xy ,vec2(a,b));
    highp float sn= mod(dt,3.14);
    return fract(sin(sn) * c);
}

void main(void) {
    vec2 st = (gl_FragCoord.xy * 2.0 - resolution.xy) / min(resolution.x, resolution.y);
    st *= 5.0;
    
    float t = time * 0.0000001;
    
    vec2 rst = mod(st,2.0);
    rst -= 1.0;
    vec2 id = rst - st;

    vec3 color = vec3(0.0);
    color.r += rand(id - t);
    color.g += rand(id - 0.1 + t);
    color.b += rand(id - 0.2 + t);

    float rnd = rand(vec2(id.y));
    float stg = smoothstep(rnd * 0.5, rnd, rnd);

    float whiteNoise = (rand(st) * 2.0 - 1.0) * (0.15 + stg * 0.15);
    color += whiteNoise;

    float waveNoisey = (sin(st.y * 100.0) + 1.0) / 2.0 * (0.15 + stg * 0.2);
    float waveNoisex = (sin(st.x * 100.0) + 1.0) / 2.0 * (0.15 + stg * 0.2);
    color -= waveNoisey + waveNoisex;
    gl_FragColor = vec4(color, 1.0);
}