varying vec2 vUv;
uniform float time;
uniform sampler2D u_texture;

// https://www.shadertoy.com/view/4djSRW
float hash12(vec2 p){
  vec3 p3  = fract(vec3(p.xyx) * .1031);
  p3 += dot(p3, p3.yzx + 33.33);
  return fract((p3.x + p3.y) * p3.z);
}

void main() {
  vec2 uv = vUv;

  uv.x *= 3.142596;

  const float numbers = 9.0;

  vec2 repeat = vec2(6.0, 12.0);

  vec2 cell = (uv * repeat);

  cell.x *= numbers;
  cell = floor(cell);

  float rand = 100.0 * hash12(cell);

  float offset = mod(floor(time + rand), numbers) / numbers;
  uv = fract(uv * repeat);
  uv.x = fract(uv.x + offset);

  vec4 color = texture2D(u_texture, uv);

  color -= 0.05 * vec4(vec3(rand), 1.0);
  gl_FragColor = color;
}