If anybody needed it:
#version 130
uniform sampler2D tex;
uniform float sigma;
#define gauss_constant 0.3989422804014327
float gauss_weight(int d)
{
return (gauss_constant/sigma)*exp(-d*d/(2*sigma*sigma));
}
void main()
{
vec3 sum = vec3(0.0);
float delta = 1.0/textureSize(tex, 0).x;
float div = 0;
sum += gauss_weight(0)*texture(tex, gl_TexCoord[0].xy).rgb;
div += gauss_weight(0);
for (int i=1; i<=3*sigma; i++)
{
sum += gauss_weight(i)*texture(tex, gl_TexCoord[0].xy+vec2(delta*i, 0)).rgb;
sum += gauss_weight(i)*texture(tex, gl_TexCoord[0].xy+vec2(-delta*i, 0)).rgb;
div += 2*gauss_weight(i);
}
gl_FragColor = vec4(sum, 1.0)/div;
}
And in sfml:
frag.setUniform("sigma", (float)sigma_input.get_data());
frag.setUniform("tex", in.get_data());
Though it slows down a bit (800ms! per x and y pass on sigma=200) so I'll be experimenting with speeding this up.
EDIT:
Indeed, computation of the gaussian weight isn't important - eliminating it doesn't change computation time pretty much at all. The blur isn't ideal (average of the gaussian function over one unit of distance isn't exactly the value in the middle of said distance) but it's much closer to the real one and suits my application.