// Constants
float4x4 World;
float4x4 View;
float4x4 Proj;

#include "dcShadowMap.HLSL"
#include "dcLighting.HLSL"

float Timer;
float FogRange;

struct VS_OUTPUT{
    float4 Pos				: POSITION;
    float4 Diffuse			: COLOR0;
    float3 Specular			: COLOR1;
	float2 BaseTex			: TEXCOORD0;
	float2 ShadowTex		: TEXCOORD1;
};

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

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

	float2 ShadowMap = ComputeShadowMap(Pos);

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

	float4 Diffuse = ComputeDiffuse(Pos, Normal);

	// Output
    VS_OUTPUT Out;
    Out.Pos = mul(float4(Pos, 1), Proj);
    Out.Diffuse = Diffuse;
     Out.Specular = Out.Pos.z * FogRange;

	Out.BaseTex = Input.BaseTex;
	Out.ShadowTex = ShadowMap;

	Out.BaseTex.x += Timer / 15.0f;
	Out.BaseTex.y += Timer / 17.5f;

    return Out;
}