// Constants
float4x4 World : register(c0);
float4x4 View : register(c4);
float4x4 Proj : register(c8);

#include "dcShadowMap_V.HLSL"

struct VS_OUTPUT{
    float4 Pos				: POSITION;
	float4 ShadowPos		: TEXCOORD0;
	float2 BaseTex			: TEXCOORD1;
	
	float2 LightDepthW		: TEXCOORD2;	
	float2 LightW			: TEXCOORD3;
};

struct VS_INPUT{
    float3 Pos				: POSITION;
    float3 Normal			: NORMAL;
    float2 BaseTex			: TEXCOORD0;
};

VS_OUTPUT main(const VS_INPUT Input){
	float4 ShadowPos;
	ComputeShadowSimple(Input.Pos, ShadowPos);
	
	// Setup
	float3 Pos = mul(float4(Input.Pos, 1), (float4x3)World);

	// View transform position
	Pos = mul(float4(Pos, 1), (float4x3)View);

	// Output
    VS_OUTPUT Out;
    Out.Pos = mul(float4(Pos, 1), Proj);
	Out.ShadowPos = ShadowPos;
	Out.BaseTex = Input.BaseTex;
	
	Out.LightDepthW = ShadowPos.z / 500;
	Out.LightW = ShadowPos.w;

    return Out;
}
