uniform sampler2D tex0;
uniform vec2 size;
uniform float fade;

void main(void)
{
	vec2 p = -1.0 + mod(gl_FragCoord, size) / size * 2.0;

//	fade = 1.0;

	float offset = -0.5 + gl_TexCoord[0].x * gl_TexCoord[0].y  * 0.5;
	float _fade = max(0.0, min(1.0, offset + fade * 2.0));

	float s = _fade * 2.0;

	float c = length(p * s);

	float fadeout = 0;
	if (_fade > 0.8)
		fadeout = (_fade - 0.8) / 0.2;

	vec4 texel = texture2D(tex0, gl_TexCoord[0]);
	float alpha = mix(c, 1.0, fadeout);

	gl_FragData[0] = vec4(texel.rgb * gl_Color.rgb, alpha * texel.a * gl_Color.a);
//	gl_FragData[0] = vec4(texel.rgb * gl_Color.rgb, texel.a);
//	gl_FragData[0] = vec4(vec3(texel.a), 1.0);
}


