dropshadow.gdshader 761 B

123456789101112131415161718192021222324
  1. shader_type canvas_item;
  2. render_mode blend_mix;
  3. uniform float radius = 5.0;
  4. uniform vec4 modulate : source_color;
  5. void fragment() {
  6. vec2 ps = TEXTURE_PIXEL_SIZE;
  7. vec4 shadow = texture(TEXTURE, UV + vec2(-radius, -radius) * ps);
  8. shadow += texture(TEXTURE, UV + vec2(-radius, 0.0) * ps);
  9. shadow += texture(TEXTURE, UV + vec2(-radius, radius) * ps);
  10. shadow += texture(TEXTURE, UV + vec2(0.0, -radius) * ps);
  11. shadow += texture(TEXTURE, UV + vec2(0.0, radius) * ps);
  12. shadow += texture(TEXTURE, UV + vec2(radius, -radius) * ps);
  13. shadow += texture(TEXTURE, UV + vec2(radius, 0.0) * ps);
  14. shadow += texture(TEXTURE, UV + vec2(radius, radius) * ps);
  15. shadow /= 8.0;
  16. shadow *= modulate;
  17. vec4 col = texture(TEXTURE, UV);
  18. COLOR = mix(shadow, col, col.a);
  19. }