uniform mat4 Eng_ObjectMatrix, Eng_ViewProjectionMatrix;
uniform float Eng_WaterMin;
uniform vec3 Eng_LocalLighting;
uniform float Offset;

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

attribute vec3 TSM0, TSM1, TSM2;

void main()
{		 	
	TexCoord0 = gl_MultiTexCoord0.xy;
 	vec4 wvert = Eng_ObjectMatrix * gl_Vertex;
 	
	vec3 Normal = vec3(TSM0.z, TSM1.z, TSM2.z);
	Clr = (max(0.0, dot(Normal, Eng_LocalLighting)) * gl_LightSource[0].diffuse) + gl_LightSource[0].ambient;
	Clr.a = 1.0;
		 	
 	wvert.z -= Offset;
	height = Eng_WaterMin - wvert.z;

 	gl_Position = Eng_ViewProjectionMatrix * wvert;
    ViewCoords = gl_Position;
}
