



vec4 samplesH[7] = { vec4(-3.0, 0.0, 0, 1.0 / 64.0),
                     vec4(-2.0, 0.0, 0, 6.0 / 64.0),
                     vec4(-1.0, 0.0, 0, 15.0 / 64.0),
                     vec4(0.0, 0.0, 0, 20.0 / 64.0),
                     vec4(1.0, 0.0, 0, 15.0 / 64.0),
                     vec4(2.0, 0.0, 0, 6.0 / 64.0),
                     vec4(3.0, 0.0, 0, 1.0 / 64.0)};

vec4 samplesV[7] = { vec4(0.0, -3.0, 0, 1.0 / 64.0),
                     vec4(0.0, -2.0, 0, 6.0 / 64.0),
                     vec4(0.0, -1.0, 0, 15.0 / 64.0),
                     vec4(0.0, 0.0, 0, 20.0 / 64.0),
                     vec4(0.0, 1.0, 0, 15.0 / 64.0),
                     vec4(0.0, 2.0, 0, 6.0 / 64.0),
                     vec4(0.0, 3.0, 0, 1.0 / 64.0)};

uniform bool vertPass;

uniform float invScreenX;
uniform float invScreenY;

uniform float brighten;
uniform float contrastPreCalc;

uniform sampler2D baseMap;
varying vec2 Texcoord;

void main(void)
{
   vec4 c = vec4(0,0,0,0);
   

   for (int i = 0; i < 7; i ++)
   {
		vec2 offset;
		
		if (vertPass)
			offset = 2.0 * vec2(samplesV[i].x * invScreenX, samplesV[i].y * invScreenY);
		else
			offset = 2.0 * vec2(samplesH[i].x * invScreenX, samplesH[i].y * invScreenY);
			
      c += samplesV[i].w * texture2D(baseMap, Texcoord + offset);
   }
   
   
	if (brighten != 0.0)
	{
		c += vec4(brighten,brighten,brighten,0);
		
		c = clamp(c, vec4(0,0,0,0), vec4(1,1,1,1));
	}
   
   if (contrastPreCalc != -1.0)
   {
		c *= contrastPreCalc;
   }
   
   gl_FragColor = c;
}