uniform float4 colorModulate;		// Added the color parameter
uniform sampler tex				: register(s0);
uniform sampler shadowmap		: register(s1);

float4 main( float2 diffuse		: TEXCOORD0,
			 float4 shadowUV	: TEXCOORD1  ) : COLOR0
{
	float4 color = tex2D(tex, diffuse);		// Sample the texture
	
	// sample the shadowmap
	// scaling by the depth coordinate?
	shadowUV = shadowUV / shadowUV.w;
	
	// this check is needed because it seems that on ATI cards, the shadowmap value is zero
	// when there is no shadowmap at all, causing the output to black out
	float4 tempColor = float4(0, 0, 0, 1);
	tempColor = tex2D(shadowmap, shadowUV);
	if( tempColor.r !=0 && tempColor.g!=0 && tempColor.b!=0 )
		color *= tempColor;
		
	return color * colorModulate;		// Multiply the pixel color by colorModulate
}
