float2 ViewSize : ViewSize;






float ImageBrightness<
	string UIWidget = "slider";
	float UIMax = 1.0;
	float UIMin = -1.0;
	float UIStep = 0.01;
> = 0;

float ImageContrast<
	string UIWidget = "slider";
	float UIMax = 1.0;
	float UIMin = 0.0;
	float UIStep = 0.01;
> = 0;

float ImageOffset<
	string UIWidget = "slider";
	float UIMax = 1.0;
	float UIMin = -1.0;
	float UIStep = 0.01;
> = 0;

float ImageStatic<
	string UIWidget = "slider";
	float UIMax = 1.0;
	float UIMin = 0.0;
	float UIStep = 0.01;
> = 0;

float ImageStaticX<
	string UIWidget = "slider";
	float UIMax = 1.0;
	float UIMin = 0.0;
	float UIStep = 0.01;
> = 0;









texture frameImg : RENDERCOLORTARGET
< 
	string ResourceName = "";
	float2 ViewportRatio = { 1.0, 1.0 };
>;

sampler2D FrameMap = sampler_state {
    Texture = < frameImg >;
    MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;
    AddressU = Clamp; AddressV = Mirror;
};










struct input 
{
	float4 pos : POSITION;
	float2 uv : TEXCOORD0;
};
 
struct output {

	float4 pos: POSITION;
	float2 uv: TEXCOORD0;

};

output VS( input IN ) 
{
	output OUT;
	float4 oPos = float4( IN.pos.xy + float2( -1.0f/ViewSize.x, 1.0f/ViewSize.y ),0.0,1.0 );
	OUT.pos = oPos;

	float2 uv = (IN.pos.xy + 1.0) / 2.0;
	uv.y = 1 - uv.y;
	
	OUT.uv = uv+float2(0,ImageOffset);
	
	return OUT;	
}



 
 
 








float4 PS( output IN, uniform sampler2D Image) : COLOR 
{
	float color=tex2D(Image,IN.uv).x+.025;
	color+=color*.25;
	
	color+=saturate(tex2D(Image,float2(ImageStaticX,IN.uv.y))-(1-ImageStatic));
	
	color = saturate(color)+ImageBrightness;
	float contrast=ImageContrast;
	
	color=color-.5;
	color/=lerp(1,length(color),ImageContrast);
	color=color+.5;
	
    return float4(color,color,color,1);
}












technique Default
<
	string RenderColorTarget = "frameImg";
>
{
	pass Final < string RenderColorTarget = ""; >
	{
		ZEnable = False;
		VertexShader = compile vs_1_1 VS();
		PixelShader = compile ps_2_0 PS( FrameMap );
	}
}