#extension GL_ARB_texture_rectangle : enable
uniform sampler2DRect tex0;

uniform float time;


void main() {
  vec2 sp = gl_TexCoord[0].xy;
  vec4 c = texture2DRect( tex0, sp );

  int width = 5;

  float totalweight = 0;
  vec4 glow = vec4(0,0,0,0);
  for (int i = -width; i < width+1; ++i) 
    for (int j = -width; j < width+1; ++j)  {
      float w = exp(-(i*i*1.0+j*j*1.0)*0.02);
      totalweight += w;
      glow += texture2DRect( tex0, sp + vec2(i*1.0,j*1.0) ) * w;
    }
          
  glow/= totalweight;
 



  gl_FragColor = glow*(0.5+0.5*cos(sp.y*0.2+time*4.0)) +c;
}



