uniform float4x4	matWorldViewProj;
uniform float4x4	matWorld;

extern uniform float worldSize;

struct VS_INPUT 
{
	float3 position						: POSITION;
	float2 uv							: TEXCOORD0;
};

struct VS_OUTPUT 
{
	float4 position						: POSITION;
	float2 uv0							: TEXCOORD0;
	float2 terrainUV					: TEXCOORD1;
	float3 wsPos						: TEXCOORD2;
};

VS_OUTPUT main( VS_INPUT input )
{
	VS_OUTPUT output;

	float4 inPosHomogeneous = float4( input.position, 1.0f );
	float4 wsPosition = mul( matWorld, inPosHomogeneous );
	output.wsPos = wsPosition.xyz;
	
	output.position =  mul( matWorldViewProj, inPosHomogeneous );

	output.uv0 = input.uv;
	output.terrainUV = float2( wsPosition.x/worldSize, wsPosition.z/worldSize );
	
	return output;
}
