uniform float compression;
uniform float saturation;

uniform sampler2DRect tex0;

void main(void)
{
	vec3 rgby= vec3(.3, .59, .11);
	vec3 color, color1, color2;
	float y, t;
	float k1= 1. / pow(saturation, 1. / compression);

	//
	color= texture2DRect(tex0, gl_TexCoord[0].st).rgb;
	y= dot(color, rgby);
		
	if(y < saturation)
	{
		color/= y;
		t= k1 * pow(y, 1. / compression);
		color= color * t;
	}
	else
	{
		color= vec3(1., 1., 1.);
	}

	gl_FragColor= vec4(color, 1.);
}

