uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D texture3;

uniform float cosprog;

void main ()
{	
	vec4 watertex = texture2D(texture1, gl_TexCoord[0].st);
	vec4 refl_Frag = texture2D(texture2, gl_TexCoord[0].st);
	vec4 refr_Frag = texture2D(texture3, gl_TexCoord[0].st);

	if (watertex.a == 0.0)
	{
		
		if (refl_Frag.a < 1.0)
		{
			gl_FragColor = vec4(refl_Frag.r/2.0, refl_Frag.g/2.0, refl_Frag.b, refl_Frag.a) + vec4(watertex.r, watertex.g, 1.0, watertex.a);
		}
		else
		{
			gl_FragColor = vec4(watertex.r, watertex.g, watertex.r+watertex.g, watertex.a);
		}
	}	
	else
	{
		gl_FragColor = watertex;
	}
}