varying float height;
varying vec2 TexCoord0;
varying vec4 Clr;
varying vec4 ViewCoords;

uniform sampler2D DiffuseMap;
uniform vec4 Eng_WaterDeepColor;
uniform sampler2D Eng_EnvWaterHeightMap;
uniform float Eng_WaterWaveHeight;

void main()
{
	vec2 C = ((ViewCoords.xy / ViewCoords.w) + 1.0) * 0.5;
	float wh = (texture2D(Eng_EnvWaterHeightMap, C).r) * Eng_WaterWaveHeight;

	if (height > wh)
  		discard;
	else
		gl_FragColor = Clr * texture2D(DiffuseMap, TexCoord0);
}
