#extension GL_ARB_texture_rectangle : enable

uniform sampler2DRect image;
void main()
{
	vec2 min_px = gl_TexCoord[0].xy;
	vec2 max_px = gl_TexCoord[1].xy;
	gl_FragColor =
		0.25 * 0.25 * (
		  texture2DRect(image, mix(min_px, max_px, vec2(0.2,0.2)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.4,0.2)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.6,0.2)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.8,0.2)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.2,0.4)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.4,0.4)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.6,0.4)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.8,0.4)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.2,0.6)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.4,0.6)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.6,0.6)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.8,0.6)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.2,0.8)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.4,0.8)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.6,0.8)))
		+ texture2DRect(image, mix(min_px, max_px, vec2(0.8,0.8)))
		)
		;
	gl_FragColor.a = 1.0;
}
