depthBoxBlur.fragment.fx 408 B

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