#define COMPILE_TARGET ps_1_4

float3 LightAmbient;
float3 LightDiffuse;

struct PS_INPUT{
	float3 Normal			: TEXCOORD0;

	float3 LightDir			: TEXCOORD1;
	float LightDepth		: TEXCOORD2;
	float4 LightProj		: TEXCOORD3;
	
	float LightW			: TEXCOORD4;
};

struct PS_OUTPUT{
    float4 Color			: COLOR;
};

#include "dcLight_Utils14.HLSL"

PS_OUTPUT main(const PS_INPUT Input){
	// Compute normal
	float3 Normal = Input.Normal;
	float3 LightDir = CubeNormalize(Input.LightDir);
		
	// Compute lighting
	float Dot = dot(LightDir, Normal);
	float DiffBlend = clamp(Dot, 0, 1);
		
	// Compute colors
	float3 Ambient = LightAmbient;
	float3 Diffuse = LightDiffuse * DiffBlend;
		
	// Compute attenuation
	float Falloff = ComputeAttenuation14(Input, Input.LightW);
		
	// Compute result
	float3 LightResult = (Ambient + Diffuse) * Falloff;

	PS_OUTPUT Out;
	Out.Color.rgb = LightResult;
	Out.Color.a = 1.0f; 
	return Out;
}