2D Glow Screen ( No WorldEnvironment Node )

create a canvas layer, add a control node to it.
make the control node to full rect. finally add a color rect node that is also full rect and apply the shader to it.
MAKE SURE HDR 2D IS ENABLED IN THE PROJECT SETTINGS
a credit is appreciated.

Sadly, I tried it on web but it did not work. It seems like web builds does not support the bias in texture methods. I opened an issue in godot github to see if they will fix it.
you can check this issue by this link:
https://github.com/godotengine/godot/issues/97943

Shader code
shader_type canvas_item;

uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap_anisotropic, repeat_disable;
uniform float hpass : hint_range(0.0, 1.0, 0.1) = 1.0;
uniform float vpass : hint_range(0.0, 1.0, 0.1) = 1.0;
uniform int radius : hint_range(0, 65, 1) = 65;
render_mode blend_add;

vec4 textureThresholded(sampler2D _texture, vec2 _uv, float _bias) {
	vec4 pixel = textureLod(_texture, _uv, _bias);
	
	if ( pixel.r <= 1. && pixel.g <= 1. && pixel.b <= 1. ) {
		pixel.rgb = vec3(0.);
	}
	
	return pixel; 
}

void fragment() {
	vec4 pixel = textureThresholded(screen_texture, SCREEN_UV, 0.);
	
	if (radius != 0) {
		
		vec4 blurred = vec4(0., 0., 0., 1.);
		float[65] w = {0.0064, 0.0063, 0.0062, 0.0061, 0.006,
			0.0059, 0.0058, 0.0057, 0.0056, 0.0055, 0.0054, 0.0053, 0.0052, 0.0051, 0.005, 0.0049, 0.0048, 0.0047, 0.0046, 0.0054, 0.0044, 0.0043, 0.0042, 0.0041, 0.004, 0.0039, 0.0038, 0.0037, 0.0036, 0.0043, 0.0034, 0.0033, 0.0032, 0.0031, 0.003, 0.0029, 0.0028, 0.0027, 0.0026, 0.0052, 0.0024, 0.0023, 0.0022, 0.0021, 0.002, 0.0019, 0.0018, 0.0017, 0.0016, 0.0051, 0.0014, 0.0013, 0.0012, 0.0011, 0.001, 0.0009, 0.0008, 0.0007, 0.0006, 0.0005, 0.0004, 0.0003, 0.0002, 0.0001, 0.};
		
		float px = 1. / float(textureSize(screen_texture, 0).x);
		float py = 1. / float(textureSize(screen_texture, 0).y);
		
		for(int i = 0; i < radius; i++) {
			float k = float(i + 1);
			
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(float(i) * cos(float(i)), 0) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(float(-i) * cos(float(i)), 0) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
			
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(0, float(i) * sin(float(i))) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(0, float(-i) * sin(float(i))) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
			
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(float(i) * cos(float(i)), float(i) * sin(float(i))) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(float(-i) * cos(float(i)), float(-i) * sin(float(i))) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
			
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(float(i) * cos(float(i)), float(-i) * sin(float(i))) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(float(-i) * cos(float(i)), float(i) * sin(float(i))) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
			
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(float(-i) * cos(float(i)), float(i) * sin(float(i))) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
			blurred += textureThresholded(screen_texture, SCREEN_UV + vec2(float(i) * cos(float(i)), float(-i) * sin(float(i))) * vec2(px, py) * vec2(hpass, vpass), k) * w[i];
		}
		
		blurred /= float(radius) / 6.;
		pixel += blurred;
		
	} else {
		pixel = vec4(0., 0., 0., 1.);
	}
	
	COLOR = pixel;
}
Live Preview
Tags
glow, glow screen, post process, screen
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.

Related shaders

This is a shader for river movement within a Line2D node

Blur with Clearing Over a Node

Pulsing Glow Effect

guest

12 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
joão
joão
1 year ago

so good

skenda
1 year ago

It’s not working for me… I set it up as intended, but nothing glows.

Me Me
Me Me
1 year ago
Reply to  skenda

You can check the demo project to check what you might have missed.
Besides enabling the HDR 2D setting in the project settings, if you set the color in the editor make sure you set the Color in the RAW tab instead of the RGB / HSV tab so you can set the RGB values to something higher than 1.

Last edited 1 year ago by Me Me
v-electronics
v-electronics
1 year ago
Reply to  skenda

I just downloaded the demo project and it really works! Godot 4.3 here.

Jreft
Jreft
1 year ago

Can this somehow be modified to work with labels? Really need glowing text, thanks!

Ryu
Ryu
1 year ago

for anyone stuck with getting this working, go to project settings, Renderer, Rendering Method, and switch to gl_compatibility

Obi-Wan Kentucky
Obi-Wan Kentucky
5 months ago
Reply to  Ryu

That solved it for me, thank you!

TheGibusGuy
TheGibusGuy
4 months ago

Quite lovely, I’ve been tinkering with it myself at the moment. I have noticed that some entries in array w were wrong though. In the link, list w1 is the current version, and w2 is a corrected one, if you’d like to update it with that.

Last edited 4 months ago by TheGibusGuy
RickyYC
RickyYC
3 months ago
Reply to  TheGibusGuy

Hello there! Are you still using godot v 4.3?
This shader work ok in 4.3 but not in 4.4 or 4.5.
Visual effect of maximized window looked dirty.

RickyYC
RickyYC
3 months ago
Reply to  RickyYC

Oh sorry. Just noticed that you’re not the author.
I’ve contacted that person on github’s issue page. But not sure when will that person reply.

RickyYC
RickyYC
3 months ago
Reply to  RickyYC

It is not a shader problem. The fact is that in Godot 4.3 the unit will return 3.xxx but in 4.4 and 4.5 will return 13.xxx. I am still checking.(My monitor resolution is 1920*1080, so 3.xxx ≈ 4 is correct)

Last edited 3 months ago by RickyYC