blur.fs 558 B

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