uniform sampler2D tex0;
uniform float amount;
uniform float magnitude;

uniform float time;


uint wang_hash(uint seed)
{
    seed = (seed ^ 61) ^ (seed >> 16);
    seed *= 9;
    seed = seed ^ (seed >> 4);
    seed *= 0x27d4eb2d;
    seed = seed ^ (seed >> 15);
    return seed;
}

float rand(uint value)
{
	return float(wang_hash(value)) * (1.0 / 4294967296.0);
}


void main(void)
{
  
  vec2 coord = gl_TexCoord[0].st;
  
	vec4 texel = texture2D(tex0, coord);
  

  texel = mix(texel, texel * magnitude * rand(gl_FragCoord.x * gl_FragCoord.y + time), amount);


	gl_FragData[0] = texel;
}
