uniform lowp sampler2D g_BottomTexture;
uniform lowp sampler2D g_SwarmTexture;
uniform lowp sampler2D g_WaterTexture;
uniform lowp float g_Alpha;

varying mediump vec2 f_bottomcoord;
varying mediump vec2 f_swarmcoord;
varying mediump vec2 f_watercoord;	// x = shift, y = depth

lowp vec3 color_sun = vec3(0.25, 0.35, 0.4);

void main(void)
{
	lowp vec3 bottom_color = texture2D(g_BottomTexture, f_bottomcoord).xyz;
    lowp vec4 swarm_color = texture2D(g_SwarmTexture, f_swarmcoord);
    lowp vec4 water_color = texture2D(g_WaterTexture, f_watercoord);

    lowp vec3 bottom_swarm = bottom_color + swarm_color.xyz * swarm_color.w;

    lowp vec3 mix_color = mix(bottom_swarm, water_color.xyz, water_color.w);

    gl_FragColor = vec4(mix_color, 1.0);

	lowp float weight_sun = (2.0 - f_bottomcoord.y - f_bottomcoord.x) * 0.35;
    weight_sun *= weight_sun;

    gl_FragColor = vec4(mix_color + color_sun * weight_sun, g_Alpha);
}