ssaoBlurFragment.fs 528 B

1234567891011121314151617181920212223
  1. #version 430
  2. layout (binding = 0) uniform sampler2D ssaoSamp;
  3. in vec2 varTex;
  4. out float color;
  5. void main()
  6. {
  7. vec2 texelSize = 1.0 / vec2(textureSize(ssaoSamp, 0));
  8. float result = 0.0;
  9. const int radius = 2;
  10. for(int x = -radius; x < radius; x++)
  11. {
  12. for(int y = -radius; y < radius; y++)
  13. {
  14. vec2 offset = vec2(float(x), float(y)) * texelSize;
  15. result += texture(ssaoSamp, varTex + offset).r;
  16. }
  17. }
  18. result /= (radius * radius * 4);
  19. color = result;
  20. }