EntityOutline.gdshader 565 B

1234567891011121314151617181920212223
  1. shader_type canvas_item;
  2. uniform vec3 outline_color : source_color = vec3(1.0, 0.0, 0.0); // Red
  3. uniform float blink_speed : hint_range(0, 10) = 1.0;
  4. const vec2 OFFSETS[8] = {
  5. vec2(-1, -1), vec2(-1, 0), vec2(-1, 1), vec2(0, -1), vec2(0, 1),
  6. vec2(1, -1), vec2(1, 0), vec2(1, 1)
  7. };
  8. void vertex() {
  9. // Nothing here for 2D sprite
  10. }
  11. void fragment() {
  12. if (COLOR.r < 0.01 && COLOR.g < 0.01 && COLOR.b < 0.01)
  13. {
  14. float sintime = sin(TIME * blink_speed);
  15. // Output the final color
  16. COLOR.rgb = mix(COLOR.rgb, outline_color, 0.5 + 0.5 * sintime);
  17. }
  18. }