Item pulse glow

Make items glow with easy to use shader params

 

Glow color

 

Intensity

 

Spread

 

Pulse speed

Shader code
shader_type canvas_item;
render_mode blend_add;
uniform vec4 glow_color : source_color = vec4(1.0, 0.9, 0.5, 1.0);
uniform float intensity : hint_range(0.0, 5.0) = 1.5;
uniform float spread : hint_range(0.1, 2.0) = 1.0;
uniform float pulse_speed : hint_range(0.0, 10.0) = 1.0;
void fragment() {
    vec2 centered_uv = UV - vec2(0.5);
    float dist = length(centered_uv) * spread;
    float alpha = max(0.0, 1.0 - dist);
    alpha *= (1.0 + 0.2 * sin(TIME * pulse_speed));
    alpha = clamp(alpha * intensity, 0.0, 1.0);
    COLOR = glow_color * alpha;
}
Live Preview
Tags
glow
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from Pheonix

Related shaders

Comments 3

  1. GameBug
    shader_type canvas_item;
    
    render_mode blend_add;
    
    uniform vec4 glow_color : source_color = vec4(1.0, 0.9, 0.5, 1.0);
    uniform float intensity : hint_range(0.0, 10.0) = 1.5;
    uniform float spread : hint_range(0.1, 10.0) = 1.0;
    uniform float pulse_speed : hint_range(0.0, 100.0) = 1.0;
    
    void fragment() {
      vec4 main_texture = texture(TEXTURE, UV); // Get existing texture
      vec2 centered_uv = UV - vec2(0.5);
      float dist = length(centered_uv) * spread;
      float alpha = max(0.0, 1.0 - dist);
      alpha *= (1.0 + 0.2 * sin(TIME * pulse_speed));
      alpha = clamp(alpha * intensity, 0.0, 1.0);
      COLOR = main_texture * glow_color * alpha; // Apply pulse with original texture
    }
    

    Updated above code to be used with an existing texture

    1
  2. xStatuzz

    I modified this to be able to fit the shape of the game object/sprite you want to add glow to.

     

    shader_type canvas_item;
    render_mode blend_add; // This makes it 'glow' against the world

     

    uniform vec4 glow_color : source_color = vec4(1.0, 0.9, 0.5, 1.0);
    uniform float intensity : hint_range(0.0, 5.0) = 1.5;
    uniform float spread : hint_range(0.1, 2.0) = 1.0;
    uniform float pulse_speed : hint_range(0.0, 10.0) = 1.0;

     

    void fragment() {
      // 1. Get the shape of your sprite
      float sprite_shape = texture(TEXTURE, UV).a;
       
      // 2. Your original circle logic
      vec2 centered_uv = UV - vec2(0.5);
      float dist = length(centered_uv) * spread;
      float alpha = max(0.0, 1.0 - dist);
       
      // 3. Your original pulse logic
      alpha *= (1.0 + 0.2 * sin(TIME * pulse_speed));
      alpha = clamp(alpha * intensity, 0.0, 1.0);
       
      // 4. THE FIX: Multiply by sprite_shape so the glow stays 
      // within the bounds of the sprite (prevents a giant square box)
      COLOR = glow_color * alpha * sprite_shape;
    }

    1