glow.gdshader 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. shader_type canvas_item;
  2. render_mode blend_premul_alpha;
  3. uniform float radius = 5.0;
  4. uniform float amount = 0.25;
  5. void fragment() {
  6. float r = radius;
  7. vec2 ps = TEXTURE_PIXEL_SIZE;
  8. vec4 col = texture(TEXTURE, UV);
  9. vec4 glow = col;
  10. glow += texture(TEXTURE, UV + vec2(-r, -r) * ps);
  11. glow += texture(TEXTURE, UV + vec2(-r, 0.0) * ps);
  12. glow += texture(TEXTURE, UV + vec2(-r, r) * ps);
  13. glow += texture(TEXTURE, UV + vec2(0.0, -r) * ps);
  14. glow += texture(TEXTURE, UV + vec2(0.0, r) * ps);
  15. glow += texture(TEXTURE, UV + vec2(r, -r) * ps);
  16. glow += texture(TEXTURE, UV + vec2(r, 0.0) * ps);
  17. glow += texture(TEXTURE, UV + vec2(r, r) * ps);
  18. r *= 2.0;
  19. glow += texture(TEXTURE, UV + vec2(-r, -r) * ps);
  20. glow += texture(TEXTURE, UV + vec2(-r, 0.0) * ps);
  21. glow += texture(TEXTURE, UV + vec2(-r, r) * ps);
  22. glow += texture(TEXTURE, UV + vec2(0.0, -r) * ps);
  23. glow += texture(TEXTURE, UV + vec2(0.0, r) * ps);
  24. glow += texture(TEXTURE, UV + vec2(r, -r) * ps);
  25. glow += texture(TEXTURE, UV + vec2(r, 0.0) * ps);
  26. glow += texture(TEXTURE, UV + vec2(r, r) * ps);
  27. glow /= 17.0;
  28. glow *= amount;
  29. col.rgb *= col.a;
  30. COLOR = glow + col;
  31. }