2014-11-14 17:52:03 -05:00
|
|
|
uniform sampler2D source;
|
2016-05-03 15:21:15 -04:00
|
|
|
layout(rgba16f) restrict writeonly uniform image2D dest;
|
2014-11-14 17:52:03 -05:00
|
|
|
uniform vec2 pixel;
|
2014-12-09 12:43:48 -05:00
|
|
|
uniform float weights[7];
|
2014-11-14 17:52:03 -05:00
|
|
|
|
|
|
|
// Gaussian separated blur with radius 6.
|
|
|
|
|
|
|
|
layout (local_size_x = 8, local_size_y = 8) in;
|
|
|
|
|
2014-11-20 15:23:33 -05:00
|
|
|
shared vec4 local_src[8][8 + 2 * 6];
|
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);
|
2015-03-15 17:37:59 -04:00
|
|
|
vec2 uv_m = (iuv - ivec2(0, 6)) * pixel;
|
|
|
|
vec2 uv = iuv * pixel;
|
|
|
|
vec2 uv_p = (iuv + ivec2(0, 6)) * pixel;
|
2014-11-14 17:52:03 -05:00
|
|
|
|
2014-11-20 15:23:33 -05:00
|
|
|
local_src[x][y] = texture(source, uv_m);
|
|
|
|
local_src[x][y + 6] = texture(source, uv);
|
|
|
|
local_src[x][y + 12] = texture(source, uv_p);
|
2014-11-14 17:52:03 -05:00
|
|
|
|
|
|
|
barrier();
|
|
|
|
|
2014-12-09 12:43:48 -05:00
|
|
|
vec4 sum = local_src[x][y + 6] * weights[0];
|
2014-11-14 17:52:03 -05:00
|
|
|
for (int i = 1; i < 6; i++) {
|
2014-12-09 12:43:48 -05:00
|
|
|
sum += local_src[x][6 + y - i] * weights[i];
|
|
|
|
sum += local_src[x][6 + y + i] * weights[i];
|
2014-11-14 17:52:03 -05:00
|
|
|
}
|
|
|
|
|
2014-11-20 15:23:33 -05:00
|
|
|
imageStore(dest, iuv, sum);
|
2014-11-14 17:52:03 -05:00
|
|
|
}
|