blur_horiz.fs 661 B

1234567891011121314151617181920212223242526272829303132
  1. #version 150
  2. uniform sampler2D source[];
  3. uniform vec4 sourceSize[];
  4. in Vertex {
  5. vec2 vTexCoord;
  6. };
  7. out vec4 FragColor;
  8. // Higher value, more centered glow.
  9. // Lower values might need more taps.
  10. #define GLOW_FALLOFF 0.35
  11. #define TAPS 4
  12. #define kernel(x) exp(-GLOW_FALLOFF * (x) * (x))
  13. void main() {
  14. vec3 col = vec3(0.0);
  15. float dx = 4.0 * sourceSize[0].z; // Mipmapped
  16. float k_total = 0.0;
  17. for (int i = -TAPS; i <= TAPS; i++)
  18. {
  19. float k = kernel(i);
  20. k_total += k;
  21. col += k * texture(source[0], vTexCoord + vec2(float(i) * dx, 0.0)).rgb;
  22. }
  23. FragColor = vec4(col / k_total, 1.0);
  24. }