uniform sampler texDiffuse		: register( s0 );
uniform sampler greyArea		: register( s1 );

static const float LOS_THRESHOLD 	= 0.75f;

extern uniform float	worldSize;
extern uniform float4	losTint;

float4 main_ps( float2 diffuseUV : TEXCOORD0, float2 greyAreaUV : TEXCOORD1) : COLOR0
{
	float4 outColor = tex2D(texDiffuse, diffuseUV);
	
	float offset = 1.0f/worldSize;
	
	// Ashwin please review : rakehsj
	float fOneTileOffset = 4*offset;
	
	float2 tempGreyAreaUV = float2( greyAreaUV.x-fOneTileOffset, greyAreaUV.y );
	float4 tempGrey = tex2D( greyArea, float2(tempGreyAreaUV.x, tempGreyAreaUV.y) );

#ifndef FUZZY_LOS 	
	if( tempGrey.r < LOS_THRESHOLD )
	{
		outColor *= losTint;
	}
#else
	// tempGrey:0.5->1.0
	outColor *= lerp( 2*losTint-1, 1, tempGrey.r);
#endif

	outColor *= 0.9f;
	
	return outColor;
}
