sampler2D Tex0;
sampler2D ShininessTex;
samplerCUBE ReflectionTex;
sampler2D RockTex;

float3 Half;

float Timer;

#include "dcShadowMap_P.HLSL"

struct PS_INPUT{
	float4 Diff				: COLOR0;
	float4 Spec				: COLOR1;
    float2 BaseTex			: TEXCOORD0;
	float3 ReflectionTex	: TEXCOORD1;
	float1 Depth			: TEXCOORD2;
	float4 ShadowPos		: TEXCOORD3;
	float2 RockTex			: TEXCOORD4;
};

struct PS_OUTPUT{
    float4 Color			: COLOR;
};

PS_OUTPUT main(const PS_INPUT Input){
	float4 BaseTexColor = tex2D(Tex0, Input.BaseTex);
	float4 ShininessColor = tex2D(ShininessTex, Input.BaseTex);
	float3 ReflectionColor = texCUBE(ReflectionTex, Input.ReflectionTex);
	float ShadowColor = ComputeShadow(Input.ShadowPos, Input.Depth);
	float4 RockColor = tex2D(RockTex, Input.RockTex);

	float4 TexColor = BaseTexColor * Input.Diff;
	TexColor.rgb += (ReflectionColor + (Input.Spec * 2)) * ShininessColor;
	TexColor.rgb *= ShadowColor;
	TexColor.rgb += lerp(0, RockColor.rgb, RockColor.a * 0.5f);
	
	/*float Color = clamp(sin(-Timer * 5 + xy.y), 0, 1);
	Color = max(Color, Color * sin(Timer * 15 + (xy.x)));
	
	TexColor.r += clamp(Color / 4, 0, 0.25f);*/
	
	PS_OUTPUT Out;
	Out.Color = TexColor;
	return Out;
}
