sampler gInputSampler : register( s0 );

float gThreshold;
float gScaleFactor;

float Luminance( float3 Color )
{
	return 
		0.3 * Color.r +
		0.6 * Color.g +
		0.1 * Color.b;
}

float4 PS_ExtractHDR( 
	float2 inTex: TEXCOORD0,
	uniform float Threshold,
	uniform float ScaleFactor ) : COLOR0
{	
	float4 Color = tex2D( gInputSampler, inTex );
	float Luminance = Luminance( Color );
	if( Luminance >= Threshold )
	{
		return float4( Color.rgb * ScaleFactor, 1.0 );
	}
	else
	{
		return float4( 0.0, 0.0, 0.0, 1.0 );
	}
} 

technique Technique0
{
    pass p0
	{		
		PixelShader = compile ps_2_0 PS_ExtractHDR( 
			gThreshold,
			gScaleFactor );	
    }
}