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

static const float LOS_THRESHOLD 	= 0.75f;

extern uniform float	worldSize;
extern uniform float4	losTint;

struct VS_INPUT 
{
	float2 uv							: TEXCOORD0;
	float2 terrainUV					: TEXCOORD1;
};

float4 main( VS_INPUT input ) : COLOR0
{
	float4 outColor = tex2D( diffuseMap, input.uv );
	
	float offset = 1/worldSize;
	
	// Ashwin please review : rakehsj
	float fOneTileOffset = 4*offset;
	
	float2 tempGreyAreaUV = float2( input.terrainUV.x-fOneTileOffset, input.terrainUV.y );
	float4 tempGrey = tex2D( greyArea, float2(tempGreyAreaUV.x, tempGreyAreaUV.y) );
	
#ifndef FUZZY_LOS 
	if( tempGrey.r < LOS_THRESHOLD )
	{
		outColor.rgb *= losTint;	
	}
#else
	// tempGrey:0.5->1.0
	outColor *= lerp( 2*losTint-1, 1, tempGrey.r);
#endif

	return outColor ;
}
