// Copyright 2006-2010 (C) - Frictional Games
//
// This file is part of HPL1 Engine
//
// For conditions of distribution and use, see copyright notice in LICENSE-shaders
//

///////////////////////////////////////////////////////
/// WATER FOG VERTEX PROGRAM ////////////
///////////////////////////////////////////////////////

vec4 position = gl_Vertex;
vec4 color = gl_Color;
vec2 uv = gl_MultiTexCoord0.xy;

out vec4 vColor;
out vec2 vUv;
out float vFogUv;

uniform mat4 worldViewProj;
uniform float fogStart;
uniform float fogEnd;
uniform float timeCount;

void main()
{
	float amp = 0.04;
	float freq = 15.0;
	float speed = 3.0;

	gl_Position = (worldViewProj * position);
	gl_Position.y += sin(timeCount*speed + (position.x)*freq)*amp;
	gl_Position.y += sin(timeCount*speed + (position.z)*freq)*amp;

	vUv = uv;
	vFogUv = (fogEnd - gl_Position.z)/(fogEnd - fogStart);

	vColor = clamp(color, vec4(0.0), vec4(1.0));
}