#ifdef VERTEX_SHADER

	struct VS_INPUT
	{
		float4 Position		: POSITION;
		float4 BlendWeight	: BLENDWEIGHT;
		float4 BlendIndices	: BLENDINDICES;	
		float3 Normal		: NORMAL;
		float4 Color		: COLOR;
		float2 Texture0		: TEXCOORD0;
		float2 Texture1		: TEXCOORD1;
	};

	struct VS_OUTPUT
	{
		float4 Position		: POSITION;
		float4 Color		: COLOR;
		float2 Texture0		: TEXCOORD0;
#if PIXEL_SHADER_SUPPORTED
		float3 Light 		: TEXCOORD1;
		float RimLight 		: TEXCOORD2;
#endif
	};

	float4x4 WorldViewProj;

#if PIXEL_SHADER_SUPPORTED
	float4 CameraDirection;
	float4 LightDirection;
	float4 LightAmbient;
	float4 LightDiffuse;
#endif

#if !PIXEL_SHADER_SUPPORTED
	float4 Color;
	float4 SurfaceColor;
#endif

	VS_OUTPUT vs_main( in VS_INPUT In )
	{
		VS_OUTPUT Out = (VS_OUTPUT) 0;
		
		Out.Position = mul(vs_skin(In.Position, In.BlendWeight, In.BlendIndices), WorldViewProj);
		Out.Texture0 = In.Texture0;	
		
#if PIXEL_SHADER_SUPPORTED
		float3 Normal = vs_skin(float4(In.Normal, 0), In.BlendWeight, In.BlendIndices).xyz;
		Out.Light = (LightAmbient.xyz + LightDiffuse.xyz * max(0.0, dot(LightDirection.xyz, -Normal))) * 0.9;
		Out.RimLight = (1 - dot(CameraDirection.xyz, -Normal)) * 0.75;
		Out.Color = In.Color;
#else
		Out.Color.rgb = Color.rgb;
		Out.Color.a = SurfaceColor.a;
#endif
		return Out;
	}

#else
	struct PS_INPUT
	{
		float4 Position		: POSITION;
		float4 Color		: COLOR;
		float2 Texture0		: TEXCOORD0;
		float3 Light 		: TEXCOORD1;
		float RimLight 		: TEXCOORD2;
	};

	struct PS_OUTPUT
	{
		float4 Color		: COLOR0;
	};

	sampler2D Tex0;

	float4 TeamColor;
	float4 SurfaceColor;
	float4 OverlayColor;

	PS_OUTPUT ps_main( in PS_INPUT In )
	{
		float4 c = tex2D(Tex0, In.Texture0);
		c.rgb 	= lerp(TeamColor.rgb, c.rgb, c.a);
		c.rgb 	*= In.Light.rgb + In.RimLight;
		c.rgb 	= lerp(c.rgb, OverlayColor.rgb, OverlayColor.a);
		c.rgb	*= SurfaceColor.rgb;
		c.a 	= SurfaceColor.a;
		
		PS_OUTPUT Out;
		Out.Color = c;
		return Out;
	}

#endif
