2013-11-30 16:33:06 -05:00
|
|
|
uniform sampler2D tex;
|
|
|
|
uniform vec2 pixel;
|
2014-11-10 15:32:04 -05:00
|
|
|
uniform float sigma;
|
2014-11-01 21:35:02 -04:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
// Gaussian separated blur with radius 6.
|
|
|
|
|
2014-01-19 13:31:00 -05:00
|
|
|
out vec4 FragColor;
|
2014-01-08 18:11:10 -05:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main()
|
|
|
|
{
|
2014-06-03 13:56:59 -04:00
|
|
|
vec2 uv = gl_FragCoord.xy * pixel;
|
|
|
|
float X = uv.x;
|
|
|
|
float Y = uv.y;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-11-01 21:35:02 -04:00
|
|
|
float g0, g1, g2;
|
|
|
|
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
|
|
|
g1 = exp(-0.5 / (sigma * sigma));
|
|
|
|
g2 = g1 * g1;
|
|
|
|
vec4 sum = texture(tex, vec2(X, Y)) * g0;
|
|
|
|
g0 *= g1;
|
|
|
|
g1 *= g2;
|
2014-11-01 21:42:44 -04:00
|
|
|
for (int i = 1; i < 6; i++) {
|
2016-06-27 07:39:20 -04:00
|
|
|
sum += texture(tex, vec2(X - float(i) * pixel.x, Y)) * g0;
|
|
|
|
sum += texture(tex, vec2(X + float(i) * pixel.x, Y)) * g0;
|
2014-11-01 21:35:02 -04:00
|
|
|
g0 *= g1;
|
|
|
|
g1 *= g2;
|
|
|
|
}
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-06-03 13:56:59 -04:00
|
|
|
FragColor = sum;
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|