uniform int bottom;
uniform int top;
uniform mat4 random;
uniform sampler2D noise;
uniform float opacity;
varying vec2 uv;

void main(void)
{
  float r[2];
  vec2 uv2 = uv;
  r[4*0 + 0] = random[0][0];
  r[4*0 + 1] = random[0][1];
  /*
  r[4*0 + 2] = random[0][2];
  r[4*0 + 3] = random[0][3];
  r[4*1 + 0] = random[1][0];
  r[4*1 + 1] = random[1][1];
  r[4*1 + 2] = random[1][2];
  r[4*1 + 3] = random[1][3];
  r[4*2 + 0] = random[2][0];
  r[4*2 + 1] = random[2][1];
  r[4*2 + 2] = random[2][2];
  r[4*2 + 3] = random[2][3];
  r[4*3 + 0] = random[3][0];
  r[4*3 + 1] = random[3][1];
  r[4*3 + 2] = random[3][2];
  r[4*3 + 3] = random[3][3];
  */
  if (int(gl_FragCoord.y) < bottom || int(gl_FragCoord.y) > top)
    discard;
  //uv.t = r[int(gl_FragCoord.x * gl_FragCoord.x * gl_FragCoord.y * gl_FragCoord.y) % 16];
  uv2.s = mod(r[1] * 0.0054 * float(gl_FragCoord.x) * 0.9 /*0.0021531 * float(gl_FragCoord.x)*/, 1.0);
  uv2.t = mod(r[0] * 0.0054 * float(gl_FragCoord.y) * 0.9 /*0.0021531 * float(gl_FragCoord.y)*/, 1.0);
  //uv2.s = uv.s;
  //uv2.t = mod(0.89 * sin(r[0] * 403.0054 * uv.t) * 0.9 /*0.0021531 * float(gl_FragCoord.y)*/, 1.0);
  gl_FragColor = vec4(vec3(1.0) - texture2D(noise, uv2).rgb, opacity);
}
