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

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

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

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

////////////////////////////////////////////////////////////////////////////////////////////////////
// Global values
////////////////////////////////////////////////////////////////////////////////////////////////////

#if MIX_SM_HIGH

	cbuffer cbInput : register( b0 )
	{
		float4 g_Params;
	};

	Texture2D g_Texture : register( t0 );
	SamplerState g_Sampler : register( s0 );
	
#else //MIX_SM_HIGH

	float4 g_Params : register( c0 );
	sampler g_Sampler : register( s0 );

#endif //MIX_SM_HIGH

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

#if MIX_SM_HIGH
	#define TEX_COLOR( uv ) g_Texture.Sample( g_Sampler, uv )
#else //MIX_SM_HIGH
	#define TEX_COLOR( uv ) tex2D( g_Sampler, uv )
#endif //MIX_SM_HIGH

//Default
#define TEXEL_SIZE g_Params.xy
#define COLOR_SCALE g_Params.z

////////////////////////////////////////////////////////////////////////////////////////////////////
// Main methods
////////////////////////////////////////////////////////////////////////////////////////////////////

//CopySamling
float4 mainCopy( PS_INPUT input ) : MSV_TARGET0
{
	return TEX_COLOR( input.tex ) * COLOR_SCALE;
}

//DawnSampling2x
float4 mainDown2x( PS_INPUT input ) : MSV_TARGET0
{
	float4 output = 0;

	for( int i = 0; i < SAMPLE2X_MAX; i++ )
	{
		output += TEX_COLOR( input.tex + ( TEXEL_SIZE * SAMPLE2X_TABLE[i] ) );
	}

	return ( output * 0.25 ) * COLOR_SCALE;
}

//DawnSampling4x
float4 mainDown4x( PS_INPUT input ) : MSV_TARGET0
{
	float4 output = 0;

	for( int i = 0; i < SAMPLE4X_MAX; i++ )
	{
		output += TEX_COLOR( input.tex + ( TEXEL_SIZE * SAMPLE4X_TABLE[i] ) );
	}

	return ( output * 0.0625 ) * COLOR_SCALE;
}
