#vertexshader

void main()
{
	gl_Position = ftransform();
	gl_TexCoord[0] = gl_MultiTexCoord0;
}

#fragmentshader

uniform sampler2D color_texture;
const float exposure = 0.4;
const float brightmax = 10.0;
const vec4 mean = vec4(1.0, 0.7, 0.5, 0.0);

void main(void)
{
	vec4 c = texture2D(color_texture, gl_TexCoord[0].xy);
	float y = dot(vec4(0.30, 0.59, 0.11, 0.0), c);
	float yd = exposure * (exposure/brightmax + 1.0) / (exposure + 1.0);
	
	/*
	c.r = c.r / (c.r + mean.r);
	c.g = c.g / (c.g + mean.g);
	c.b = c.b / (c.b + mean.b);
	*/

	gl_FragColor = c;//*yd; // + vec4(1,1,1,1)*max(y-1.0, 0.0); // * yd;
	
	/*
	float y = (0.257 * c.r) + (0.504 * c.g) + (0.098 * c.b); // + 16
	//Cr = V =  (0.439 * R) - (0.368 * G) - (0.071 * B) + 128
	//Cb = U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128
	
	//gl_FragColor = vec4(y,y,y,1.0);
	
	if(y > 1.0)
		gl_FragColor = vec4(c.rgb, 1.0);
	else
		gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);*/
}

