2014-11-14 17:52:03 -05:00
|
|
|
uniform sampler2D source;
|
|
|
|
uniform layout(rgba16f) restrict writeonly image2D dest;
|
|
|
|
uniform vec2 pixel;
|
|
|
|
uniform float sigma;
|
|
|
|
|
|
|
|
// Gaussian separated blur with radius 6.
|
|
|
|
|
|
|
|
layout (local_size_x = 8, local_size_y = 8) in;
|
|
|
|
|
2014-11-15 13:18:07 -05:00
|
|
|
shared vec3 local_src[8 + 2 * 6][8];
|
2014-11-14 17:52:03 -05:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
int x = int(gl_LocalInvocationID.x), y = int(gl_LocalInvocationID.y);
|
|
|
|
ivec2 iuv = ivec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y);
|
2014-11-15 13:18:07 -05:00
|
|
|
vec2 uv_m = (iuv - ivec2(6, 0)) * pixel;
|
2014-11-14 17:52:03 -05:00
|
|
|
vec2 uv = iuv * pixel;
|
2014-11-15 13:18:07 -05:00
|
|
|
vec2 uv_p = (iuv + ivec2(6, 0)) * pixel;
|
2014-11-14 17:52:03 -05:00
|
|
|
|
|
|
|
local_src[x][y] = texture(source, uv_m).rgb;
|
2014-11-15 13:18:07 -05:00
|
|
|
local_src[x + 6][y] = texture(source, uv).rgb;
|
|
|
|
local_src[x + 12][y] = texture(source, uv_p).rgb;
|
2014-11-14 17:52:03 -05:00
|
|
|
|
|
|
|
barrier();
|
|
|
|
|
|
|
|
float g0, g1, g2;
|
|
|
|
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
|
|
|
g1 = exp(-0.5 / (sigma * sigma));
|
|
|
|
g2 = g1 * g1;
|
2014-11-15 13:18:07 -05:00
|
|
|
vec3 sum = local_src[x + 6][y] * g0;
|
2014-11-14 17:52:03 -05:00
|
|
|
g0 *= g1;
|
|
|
|
g1 *= g2;
|
|
|
|
for (int i = 1; i < 6; i++) {
|
2014-11-15 13:18:07 -05:00
|
|
|
sum += local_src[6 + x - i][y] * g0;
|
|
|
|
sum += local_src[6 + x + i][y] * g0;
|
2014-11-14 17:52:03 -05:00
|
|
|
g0 *= g1;
|
|
|
|
g1 *= g2;
|
|
|
|
}
|
|
|
|
|
|
|
|
imageStore(dest, iuv, vec4(sum, 0.));
|
|
|
|
}
|