
uniform sampler2D t_color;
uniform vec2 radius;
uniform float bias;
uniform float scale;


void main(void) {
  vec2 texcoord = gl_TexCoord[0].xy;
  vec4 col = vec4(0.0);


  // loop unrolled cause ati sucks ass
  col += texture2D(t_color, texcoord-6.0*radius)*0.002216;
  col += texture2D(t_color, texcoord-5.0*radius)*0.008764;
  col += texture2D(t_color, texcoord-4.0*radius)*0.026995;
  col += texture2D(t_color, texcoord-3.0*radius)*0.064759;
  col += texture2D(t_color, texcoord-2.0*radius)*0.120985;
  col += texture2D(t_color, texcoord-1.0*radius)*0.176033;
  col += texture2D(t_color, texcoord           )*0.199471;
  col += texture2D(t_color, texcoord+1.0*radius)*0.176033;
  col += texture2D(t_color, texcoord+2.0*radius)*0.120985;
  col += texture2D(t_color, texcoord+3.0*radius)*0.064759;
  col += texture2D(t_color, texcoord+4.0*radius)*0.026995;
  col += texture2D(t_color, texcoord+5.0*radius)*0.008764;
  col += texture2D(t_color, texcoord+6.0*radius)*0.002216;


	float bri2[13] = float[13](0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3);
  
  col += texture2D(t_color, texcoord)*0.199471;
  for(int i=0;i<20;i++) {
	float bri = (1.0-(20.0-i)/20.0);
	bri = bri2[i];
//	bri *= bri;
	bri = 1.0-bri;
	bri *= 0.05;
	col += texture2D(t_color, texcoord-i*radius)*bri;
	col += texture2D(t_color, texcoord+i*radius)*bri;
  }

  col = clamp((col + bias) * scale, 0.0, 1.0);
  gl_FragColor = col;
}
