uniform sampler2D texture0;
uniform vec3 intensity;	//rgb is intensity, a is inversion.
uniform float inversion;
void main()
{

	vec2 blur = vec2(768, 1366) * 0.000005;
	gl_FragColor.w = 1.0;
	//Simple passthrough, outputs interpolated vertex colours.
	/*
	vec4 textureColour = vec4(0,0,0,0);//texture2D(texture0, gl_TexCoord[0].xy, lodBias);
	
	//Poisson blur taps taken from ATI paper "Efficient Shader Tricks" by Chris Oat
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(-0.840144,-0.07358) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(-0.326212,-0.40581) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(-0.203345,0.620716) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(-0.695914,0.457137) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(0.473434,-0.480026) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(0.96234,-0.194983) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(0.185461,-0.893124) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(0.519456,0.767022) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(0.89642,0.412458) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(0.507431,0.064425) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(-0.791559,-0.59771) * blur);
	textureColour += texture2D(texture0, gl_TexCoord[0].xy + vec2(-0.32194,-0.932615) * blur);
	
	textureColour /= 12.0;*/
	
	vec4 textureColour = texture2D(texture0, gl_TexCoord[0].xy);
	float lum = max(textureColour.r, max(textureColour.g, textureColour.b));
	lum = dot (textureColour.rgb, vec3(0.3333, 0.5, 0.1666));
	//gl_FragColor.xyz = vec3(lum);
	
	gl_FragColor.xyz = textureColour.xyz;
	vec4 invertedColour;
	invertedColour = 1.0 - gl_FragColor;
	
	
	gl_FragColor = vec4(((1.0 - inversion) * gl_FragColor.xyz + inversion * invertedColour.xyz), 1.0);
	
	gl_FragColor.xyz *= intensity;
	
	//lum = dot (gl_FragColor.xyz, vec3(0.3333, 0.5, 0.1666));
	//lum = dot (gl_FragColor.xyz, vec3(1, 1, 1));
//	gl_FragColor.xyz = vec3(lum);
	
	//float maxRedGreen = max (gl_FragColor.x, gl_FragColor.y);
	//gl_FragColor.xy = vec2 (maxRedGreen);
}