gaussian6h.comp 928 B

12345678910111213141516171819202122232425262728293031323334
  1. uniform sampler2D source;
  2. uniform layout(rgba16f) restrict writeonly image2D dest;
  3. uniform vec2 pixel;
  4. uniform float weights[7];
  5. // Gaussian separated blur with radius 6.
  6. layout (local_size_x = 8, local_size_y = 8) in;
  7. shared vec4 local_src[8 + 2 * 6][8];
  8. void main()
  9. {
  10. int x = int(gl_LocalInvocationID.x), y = int(gl_LocalInvocationID.y);
  11. ivec2 iuv = ivec2(gl_GlobalInvocationID.x, gl_GlobalInvocationID.y);
  12. vec2 uv_m = (iuv - ivec2(6, 0)) * pixel;
  13. vec2 uv = iuv * pixel;
  14. vec2 uv_p = (iuv + ivec2(6, 0)) * pixel;
  15. local_src[x][y] = texture(source, uv_m);
  16. local_src[x + 6][y] = texture(source, uv);
  17. local_src[x + 12][y] = texture(source, uv_p);
  18. barrier();
  19. vec4 sum = local_src[x + 6][y] * weights[0];
  20. for (int i = 1; i < 6; i++) {
  21. sum += local_src[6 + x - i][y] * weights[i];
  22. sum += local_src[6 + x + i][y] * weights[i];
  23. }
  24. imageStore(dest, iuv, sum);
  25. }