uniform sampler2D texture;
uniform float blur_radius;
void main()
{
vec2 offx = vec2(blur_radius, 0.0);
vec2 offy = vec2(0.0, blur_radius);
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy) * 4.0 +
texture2D(texture, gl_TexCoord[0].xy - offx) * 2.0 +
texture2D(texture, gl_TexCoord[0].xy + offx) * 2.0 +
texture2D(texture, gl_TexCoord[0].xy - offy) * 2.0 +
texture2D(texture, gl_TexCoord[0].xy + offy) * 2.0 +
texture2D(texture, gl_TexCoord[0].xy - offx - offy) * 1.0 +
texture2D(texture, gl_TexCoord[0].xy - offx + offy) * 1.0 +
texture2D(texture, gl_TexCoord[0].xy + offx - offy) * 1.0 +
texture2D(texture, gl_TexCoord[0].xy + offx + offy) * 1.0;
gl_FragColor = gl_Color * (pixel / 16.0);
}
It looks like you're not actually using a gaussian curve for your blur. Take a look at the shader included in the SFML Game Dev book (https://github.com/SFML/SFML-Game-Development-Book/blob/master/08_Graphics/Media/Shaders/GuassianBlur.frag) (note the multiplication of the small numbers which make up the curve), it has some pretty good results:
(http://djfallen.com/images/blur.png)
>> x = [-12:1:12];
>> norm = normpdf(x,0,2.0);
>> norm
norm =
Columns 1 through 10
0.0000 0.0002 0.0005 0.0015 0.0038 0.0087 0.0180 0.0332 0.0547 0.0807
Columns 11 through 20
0.1065 0.1258 0.1330 0.1258 0.1065 0.0807 0.0547 0.0332 0.0180 0.0087
Columns 21 through 25
0.0038 0.0015 0.0005 0.0002 0.0000
uniform sampler2D texture;
uniform vec2 blur_radius;
void main() {
vec2 textureCoordinates = gl_TexCoord[0].xy;
vec4 color = vec4(0.0);
color += texture2D(texture, textureCoordinates - 10.0 * blur_radius) * 0.0012;
color += texture2D(texture, textureCoordinates - 9.0 * blur_radius) * 0.0015;
color += texture2D(texture, textureCoordinates - 8.0 * blur_radius) * 0.0038;
color += texture2D(texture, textureCoordinates - 7.0 * blur_radius) * 0.0087;
color += texture2D(texture, textureCoordinates - 6.0 * blur_radius) * 0.0180;
color += texture2D(texture, textureCoordinates - 5.0 * blur_radius) * 0.0332;
color += texture2D(texture, textureCoordinates - 4.0 * blur_radius) * 0.0547;
color += texture2D(texture, textureCoordinates - 3.0 * blur_radius) * 0.0807;
color += texture2D(texture, textureCoordinates - 2.0 * blur_radius) * 0.1065;
color += texture2D(texture, textureCoordinates - blur_radius) * 0.1258;
color += texture2D(texture, textureCoordinates) * 0.1330;
color += texture2D(texture, textureCoordinates + blur_radius) * 0.1258;
color += texture2D(texture, textureCoordinates + 2.0 * blur_radius) * 0.1065;
color += texture2D(texture, textureCoordinates + 3.0 * blur_radius) * 0.0807;
color += texture2D(texture, textureCoordinates + 4.0 * blur_radius) * 0.0547;
color += texture2D(texture, textureCoordinates + 5.0 * blur_radius) * 0.0332;
color += texture2D(texture, textureCoordinates + 6.0 * blur_radius) * 0.0180;
color += texture2D(texture, textureCoordinates - 7.0 * blur_radius) * 0.0087;
color += texture2D(texture, textureCoordinates - 8.0 * blur_radius) * 0.0038;
color += texture2D(texture, textureCoordinates - 9.0 * blur_radius) * 0.0015;
color += texture2D(texture, textureCoordinates - 10.0 * blur_radius) * 0.0012;
gl_FragColor = color;
}