// Global constants
float4x4 worldViewProj;
float4x4 world;
float4 eyePosition;
float4x4 view;
float4 lightDirection;

// Output structure
struct VS_OUTPUT
{
	float4 position : POSITION;
	float3 normal : TEXCOORD0;
	float3 viewDir : TEXCOORD1;
	float3 lightDir : TEXCOORD2;
	float depth : TEXCOORD3;
};

// Entry point
VS_OUTPUT Main( float4 position : POSITION, float3 normal : NORMAL)
{
	VS_OUTPUT outputVertex = (VS_OUTPUT)0;
	
	// Transforms the position and sets position
	outputVertex.position = mul(position, worldViewProj);
	
	// Transforms the normal and sets normal
	outputVertex.normal = mul(normal, world);
	
	float4 posWorld = mul(position, world);
	
		// Sets light
	outputVertex.lightDir = lightDirection;
	
	// Set view dir
	outputVertex.viewDir = eyePosition - posWorld;
	
	float4 posView = mul(posWorld, view);
	outputVertex.depth = -1.0 * posView.z;
	
	return outputVertex;
}