depthBoxBlur.fragment.fx 436 B

123456789101112131415161718192021
  1. #ifdef GL_ES
  2. precision highp float;
  3. #endif
  4. // Samplers
  5. varying vec2 vUV;
  6. uniform sampler2D textureSampler;
  7. // Parameters
  8. uniform vec2 screenSize;
  9. void main(void)
  10. {
  11. vec4 colorDepth = vec4(0.0);
  12. for (int x = -OFFSET; x <= OFFSET; x++)
  13. for (int y = -OFFSET; y <= OFFSET; y++)
  14. colorDepth += texture2D(textureSampler, vUV + vec2(x, y) / screenSize);
  15. gl_FragColor = (colorDepth / float((OFFSET * 2 + 1) * (OFFSET * 2 + 1)));
  16. }