The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+7 votes

This is slightly different than http://www.godotengine.org/qa/1501/adding-a-glow-effect-to-2d-sprites?show=1501#q1501:
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?

in Engine by (29,360 points)

Partly related: Explanation of HDR in 2D.

I tried the approach, but my objects only gets brighter: http://zylannprods.fr/dl/godot/Glow.zip
- Do we really need HDR to make things glow?
- Can we choose the glow curve or shader to generate the glow?

1 Answer

+1 vote

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 :)

by (331 points)

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".

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.