aura.gdshader 835 B

1234567891011121314151617181920212223242526272829303132333435
  1. shader_type canvas_item;
  2. render_mode blend_premul_alpha;
  3. // This shader only works properly with premultiplied alpha blend mode.
  4. uniform float aura_width = 2.0;
  5. uniform vec4 aura_color : source_color;
  6. void fragment() {
  7. vec4 col = texture(TEXTURE, UV);
  8. vec2 ps = TEXTURE_PIXEL_SIZE;
  9. float a;
  10. float maxa = col.a;
  11. float mina = col.a;
  12. a = texture(TEXTURE, UV + vec2(0.0, -aura_width) * ps).a;
  13. maxa = max(a, maxa);
  14. mina = min(a, mina);
  15. a = texture(TEXTURE, UV + vec2(0.0, aura_width) * ps).a;
  16. maxa = max(a, maxa);
  17. mina = min(a, mina);
  18. a = texture(TEXTURE, UV + vec2(-aura_width, 0.0) * ps).a;
  19. maxa = max(a, maxa);
  20. mina = min(a, mina);
  21. a = texture(TEXTURE, UV + vec2(aura_width, 0.0) * ps).a;
  22. maxa = max(a, maxa);
  23. mina = min(a, mina);
  24. col.rgb *= col.a;
  25. COLOR = col;
  26. COLOR.rgb += aura_color.rgb * (maxa - mina);
  27. }