#version 130

uniform sampler2D t0;
uniform vec2 vsize;

void main(void) {
	vec2 tc = gl_TexCoord[0].xy;//, dt = 1. / vsize;
	vec3 dc0 = texture2D(t0, tc).rgb, dc1 = textureOffset(t0, tc, ivec2(1, 0)).rgb, dc2 = textureOffset(t0, tc, ivec2(0, 1)).rgb, dc3 = textureOffset(t0, tc, ivec2(1, 1)).rgb;
	gl_FragColor.rgb = vec3(max(max(max(dc0.r, dc1.r), dc2.r), dc3.r), min(min(min(dc0.g, dc1.g), dc2.g), dc3.g), (dc0.b + dc1.b + dc2.b + dc3.b) / 4.);
}
