uniform sampler2D tex;
uniform float invTexHeight;


void main()
{	
	vec2 p = gl_TexCoord[0].xy;
	vec2 dp = vec2(0.0, invTexHeight);
	
	const vec3 limit = vec3(0.5,0.5,0.5);
	const vec3 mini = vec3(0.0,0.0,0.0);
	
	vec3 a = max(mini, texture2D(tex, p - 2.1428571 * dp).rgb - limit);
	vec3 b = max(mini, texture2D(tex, p - 0.6 * dp).rgb - limit);
	vec3 c = max(mini, texture2D(tex, p + 0.6 * dp).rgb - limit);
	vec3 d = max(mini, texture2D(tex, p + 2.1428571 * dp).rgb - limit);
	vec3 final = vec3(2.0 * 0.21875)  * (a + d)
	           + vec3(2.0 * 0.78125)  * (b + c);	
	gl_FragColor = vec4( final, 1.0 );
	
}