// Mikkel Gjøl, s971661 'at' student 'dot' dtu 'dot' dk
/////////////////////////////////////////


struct v2f {
	float4 position	: POSITION;
	float2 tex0		: TEXCOORD0;
};


//note: sakset fra gpu-gems1, s.364
//TODO: fjern normaliseringer - de er der kun for at matche værdier fra ps
//TODO: case ud på f.eks. gamma==1?

void main(	in const v2f IN,
						in uniform samplerRECT tex0 : TEXUNIT0,
						in uniform float inBlack,
						in uniform float inWhite,
						in uniform float Gamma,
						in uniform float outBlack,
						in uniform float outWhite,
						out float4 colOut : COLOR0 )
{

	const float4 img = texRECT( tex0, IN.tex0 );
	colOut = ( pow( max(float4(0,0,0,0),(img * 255.0f) - inBlack) / (inWhite-inBlack), Gamma) * (outWhite-outBlack) + outBlack)/255.0f;
	
	//ATI-bitch!
	//colOut = ( ( ((img * 255.0f) - inBlack) / (inWhite-inBlack)) * (outWhite-outBlack) + outBlack)/255.0f;
	
}
