uniform float4x4	matWorldViewProj;

static const int  	NUM_LIGHTS = 2;

struct VS_INPUT 
{
	float3 position						: POSITION;
	float2 uv0							: TEXCOORD0;
	float3 normal						: NORMAL;
	float3 tangent						: TANGENT0;
};

struct VS_OUTPUT 
{
	float4 position						: POSITION;
	float2 uv0 							: TEXCOORD0;
	float4 color						: COLOR0;
};

uniform float3 wsLightDir[NUM_LIGHTS];
uniform float3 lightAmbient[NUM_LIGHTS];
uniform float3 lightDiffuse[NUM_LIGHTS];

VS_OUTPUT main_vs( VS_INPUT input )
{
	VS_OUTPUT output;

	float4 inPosHomogeneous = float4( input.position, 1.0f );
	output.position =  mul(matWorldViewProj, inPosHomogeneous );
	output.uv0 = input.uv0;

	// terrain uses only one light source
	float nDotL = dot(input.normal, wsLightDir[0]);
	float3 l = lightAmbient[0] + lightDiffuse[0] * max( 0, nDotL );

	output.color.rgb = saturate(l + l);
	output.color.a = 1;

	return output;
}
