////////////////////////////////////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////////////////////////////////////

#include "../../../types.txt"

////////////////////////////////////////////////////////////////////////////////////////////////////
// Structures
////////////////////////////////////////////////////////////////////////////////////////////////////

struct PS_INPUT
{
#if MIX_SM_HIGH
	float4 pos : SV_POSITION;
#endif //MIX_SM_HIGH
	float2 tex : TEXCOORD0;
};

////////////////////////////////////////////////////////////////////////////////////////////////////
// Grobal values
////////////////////////////////////////////////////////////////////////////////////////////////////

#if MIX_SM_HIGH
	Texture2D    g_ColorTexture : register( t0 );
	SamplerState g_ColorSampler : register( s0 );
#else //MIX_SM_HIGH
	sampler g_ColorSampler : register( s0 );
#endif //MIX_SM_HIGH

////////////////////////////////////////////////////////////////////////////////////////////////////
// Macros
////////////////////////////////////////////////////////////////////////////////////////////////////

#if MIX_SM_HIGH
	#define TEX_COLOR( uv ) g_ColorTexture.Sample( g_ColorSampler, uv )
#else //MIX_SM_HIGH
	#define TEX_COLOR( uv ) tex2D( g_ColorSampler, uv )
#endif //MIX_SM_HIGH

////////////////////////////////////////////////////////////////////////////////////////////////////
// Main function - Jim Hejl
////////////////////////////////////////////////////////////////////////////////////////////////////

float4 main( PS_INPUT input ) : MSV_TARGET0
{
	float4 output = TEX_COLOR( input.tex );
	float3 x = max( 0.0, output.rgb - 0.004 );

	output.rgb = ( x * ( 6.2 * x + 0.5 ) ) / ( x * ( 6.2 * x + 1.7 ) + 0.06 );
	output.rgb = pow( output.rgb, 2.2 );

	return output;
}
