No Description

blur.frag 650B

12345678910111213141516171819202122232425262728
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (binding = 0) uniform sampler2D samplerSSAO;
  5. layout (location = 0) in vec2 inUV;
  6. layout (location = 0) out float outFragColor;
  7. void main()
  8. {
  9. const int blurRange = 2;
  10. int n = 0;
  11. vec2 texelSize = 1.0 / vec2(textureSize(samplerSSAO, 0));
  12. float result = 0.0;
  13. for (int x = -blurRange; x < blurRange; x++)
  14. {
  15. for (int y = -blurRange; y < blurRange; y++)
  16. {
  17. vec2 offset = vec2(float(x), float(y)) * texelSize;
  18. result += texture(samplerSSAO, inUV + offset).r;
  19. n++;
  20. }
  21. }
  22. outFragColor = result / (float(n));
  23. }