How to add glow to any 2D object?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zylann
:warning: Old Version Published before Godot 3 was released.

This is slightly different than Adding A Glow Effect to 2D sprites - Godot Engine - Q&A
I need to add glow to 2D objects. I checked the sprite_shaders demo, but it only works because sprites have alpha around them, and if the glow goes beyond it gets cut (look at the feets of the “glow” sprite in the demo).
If I want to make a custom-drawn line to glow, or any 2D object, what would be the way to go with shaders?

I guess it would be some kind of glow buffer that is add-blended at some point when rendering the level, is there something built-in?

Partly related: Explanation of HDR in 2D.

Bojidar Marinov | 2016-03-22 14:26

I tried the approach, but my objects only gets brighter:

  • Do we really need HDR to make things glow?
  • Can we choose the glow curve or shader to generate the glow?

Zylann | 2016-03-22 19:11

:bust_in_silhouette: Reply From: Brinux

One possibility would be to create a duplicate of the sprite you want to make glow; make the duplicate a child of the original.
Change the Modulate value for this duplicate to something bright yellow/blue etc., or whatever color you want to make the glow.
Scale it up x & y slightly, like 1.1.
Then turn on the checkbox “Behind parent” so that of your sprite so it will be behind your original.
Next, drop the opacity to between .5 and .8, so it’s somewhat translucent.
Finally, change the “Blend Mode” to “Add”, which will brighten it up.
(Alternatively you could hand paint the glow you want to use in GIMP etc. and follow the same steps)
At this point, you should see a colored light around the edges of your original sprite.
Now whenever you want the glow, you just turn on the glow-sprite’s visibility, and turn off the visibility when the glow should end.
Hope that helps :slight_smile:

Better than my original comment, there is a terrific example of how to make something glow in the Godot official examples.
Edit the one called “2D Shaders for Sprites”. There’s a screen of 10 different shader examples, and number 9 is “glow”.
Click on the node called “glow”, then the magic is in the “Material”.

Brinux | 2016-04-05 13:58

Can you link to the example you reference from the docs? I can’t find it.

Diet Estus | 2018-04-17 16:48

It’s here : 2d Shaders for Sprites

idkaryan | 2019-09-24 12:49