stk-code_catmod/data/shaders/gaussian6v.comp
2015-02-23 21:41:22 +01:00

35 lines
972 B
Plaintext

uniform sampler2D source;
uniform layout(rgba16f) restrict writeonly image2D dest;
uniform vec2 pixel;
uniform float weights[7];
// Gaussian separated blur with radius 6.
layout (local_size_x = 8, local_size_y = 8) in;
shared vec4 local_src[8][8 + 2 * 6];
void main()
{
int x = int(gl_LocalInvocationID.x), y = int(gl_LocalInvocationID.y);
ivec2 iuv = ivec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y);
vec2 guv = gl_GlobalInvocationID.xy + .5;
vec2 uv_m = (guv - vec2(0, 6)) * pixel;
vec2 uv = guv * pixel;
vec2 uv_p = (guv + vec2(0, 6)) * pixel;
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);
barrier();
vec4 sum = local_src[x][y + 6] * weights[0];
for (int i = 1; i < 6; i++) {
sum += local_src[x][6 + y - i] * weights[i];
sum += local_src[x][6 + y + i] * weights[i];
}
imageStore(dest, iuv, sum);
}