//Global Defines
#if defined(__RESHADE__) && __RESHADE__ >= 1700
	#define NAMESPACE_ENTER(name) namespace name {
	#define NAMESPACE_LEAVE() }
#else
	#define NAMESPACE_ENTER(name)
	#define NAMESPACE_LEAVE()
#endif

#define STR(name) #name
#define EFFECT(l,n) STR(ReShade/l/##n.h)

//Global Variables
#define RFX_pixelSize float2(1.0f/BUFFER_WIDTH, 1.0f/BUFFER_HEIGHT)
#define RFX_ScreenSize float2(BUFFER_WIDTH,BUFFER_HEIGHT)
#define RFX_ScreenSizeFull float4(BUFFER_WIDTH, BUFFER_RCP_WIDTH, float(BUFFER_WIDTH) / float(BUFFER_HEIGHT), float(BUFFER_HEIGHT) / float(BUFFER_WIDTH)) //x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY

//Global Textures
texture RFX_depthBufferTex : DEPTH;
texture2D RFX_backbufferTex : COLOR;
texture2D RFX_originalTex { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = RGBA8; };

//Global Samplers
sampler RFX_depthColor { Texture = RFX_depthBufferTex; };
sampler2D RFX_backbufferColor { Texture = RFX_backbufferTex; };
sampler2D RFX_originalColor { Texture = RFX_originalTex; };

//Vertex Shader
void RFX_VS_PostProcess(in uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD)
{
	texcoord.x = (id == 2) ? 2.0 : 0.0;
	texcoord.y = (id == 1) ? 2.0 : 0.0;
	pos = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

//Store Original Shader
void RFX_PS_Original(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 RFX_originalT : SV_Target0)
{
	RFX_originalT = tex2D(RFX_backbufferColor, texcoord);
}

technique RFX_StoreOriginal_Tech < enabled = true; >
{
	pass
	{
		VertexShader = RFX_VS_PostProcess;
		PixelShader = RFX_PS_Original;
		RenderTarget = RFX_originalTex;	
	}
}