/*=============================================================================
	SimpleElementMaskedPixelShader.hlsl: Pixel shader for drawing simple elements with an alpha mask when FP Blend is not available
	Copyright © 2006 Epic Games and NSE, Inc. All Rights Reserved.
=============================================================================*/

sampler2D Texture;

half Gamma;

#if XBOX
// SimpleElement rendering can not limited to just SceneColor render target
// So, SCENE_COLOR_BIAS_FACTOR has to be set as a shader param.
float SceneColorBiasFactor;
float4 BiasColor( float4 Color )
{
	return float4( Color.rgb * SceneColorBiasFactor, Color.a );
}
#define RETURN_COLOR( Color ) BiasColor( Color );
#else
#define RETURN_COLOR( Color ) ( Color )
#endif

void Main(
	in float2 TextureCoordinate : TEXCOORD0,
	in float4 Color : COLOR,
	out float4 OutColor : COLOR0
	)
{
	OutColor = tex2D(Texture,TextureCoordinate) * Color;	
	
	#if !SUPPORTS_FP_BLENDING
		clip( OutColor.a - 0.5 );
	#endif
	
	if( Gamma != 1.0 )
	{
		// Gamma correct the output color.
		OutColor.rgb = pow(saturate(OutColor.rgb),Gamma);	
	}
	OutColor = RETURN_COLOR(OutColor);
}
