#version 120
uniform sampler2D iChannel0;

uniform float time;

uniform vec2 size;

uniform float strength;
uniform float scale;

void main()
{
	float c1 = cos(time/24.0)*strength*0.2;
	float s1 = sin(time/24.0)*strength*0.2;

	float c2 = cos(time/12.0)*strength*0.1;
	float s2 = sin(time/12.0)*strength*0.1;

	mat2 matrix1 = mat2(1.0 + c1,c1,s1,1.0 + s1);
	mat2 matrix2 = mat2(1.0 - c2,c2,s2,1.0 + s2);

	vec2 xy1 = (gl_TexCoord[0].xy - 0.5)/scale*matrix1 + 0.5;
	vec2 xy2 = (gl_TexCoord[0].xy - 0.5)/scale*matrix2 + 0.5;

	xy1 = (floor(xy1*size) + 0.5)/size;
	xy2 = (floor(xy2*size) + 0.5)/size;

	float alpha1 = texture2D(iChannel0, xy1).a;
	float alpha2 = texture2D(iChannel0, xy2).a;
	float alpha = (alpha1 + alpha2)*0.5;

	gl_FragColor = gl_Color*alpha;
}