bloom_blur.glslf 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #version GLSL_VERSION
  2. #include <precision_statement.glslf>
  3. #include <std.glsl>
  4. uniform vec2 u_texel_size;
  5. uniform sampler2D u_color;
  6. /*==============================================================================
  7. SHADER INTERFACE
  8. ==============================================================================*/
  9. GLSL_IN vec2 v_texcoord;
  10. //------------------------------------------------------------------------------
  11. GLSL_OUT vec4 GLSL_OUT_FRAG_COLOR;
  12. /*==============================================================================
  13. MAIN
  14. ==============================================================================*/
  15. void main(void) {
  16. vec2 offset = vec2(0.0, 0.0);
  17. vec2 delta = u_texel_size;
  18. vec4 def_color = GLSL_TEXTURE(u_color, v_texcoord);
  19. GLSL_OUT_FRAG_COLOR = def_color * 0.0875447373698;
  20. offset += delta;
  21. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord+offset) * 0.0858112354248;
  22. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord-offset) * 0.0858112354248;
  23. offset += delta;
  24. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord+offset) * 0.0808139781061;
  25. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord-offset) * 0.0808139781061;
  26. offset += delta;
  27. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord+offset) * 0.0731235112908;
  28. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord-offset) * 0.0731235112908;
  29. offset += delta;
  30. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord+offset) * 0.0635705267419;
  31. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord-offset) * 0.0635705267419;
  32. offset += delta;
  33. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord+offset) * 0.0530985673112;
  34. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord-offset) * 0.0530985673112;
  35. offset += delta;
  36. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord+offset) * 0.0426125984122;
  37. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord-offset) * 0.0426125984122;
  38. offset += delta;
  39. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord+offset) * 0.0328565115809;
  40. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord-offset) * 0.0328565115809;
  41. offset += delta;
  42. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord+offset) * 0.0243407024472;
  43. GLSL_OUT_FRAG_COLOR += GLSL_TEXTURE(u_color, v_texcoord-offset) * 0.0243407024472;
  44. GLSL_OUT_FRAG_COLOR = max(0.7 * def_color, GLSL_OUT_FRAG_COLOR);
  45. }