uniform sampler2D tex0;
uniform int time;
uniform int offset;
uniform int speed;

void main(void)
{
	float twoPi = 2.0 * 3.141592654;

	vec2 uv = gl_TexCoord[0].st;

	float duration = 2000.0 + float(speed) * 200.0;

	float period = 0.7 + float(8 - speed) * 0.5;
	float amplitude = 0.2;
	float phase = mod(time + offset, duration) / duration;
	float thick = 1.0 + sin(phase * twoPi + uv.t * twoPi * period) * amplitude;

	thick = mix(thick, 1.0, min(1.0, uv.t * 1.2));

	uv.s = ((-1.0 + 2.0 * uv.s) * thick) * 0.5 + 0.5;

	vec4 color = texture2D(tex0, uv);

	gl_FragData[0] = color * gl_Color;
}
