Color vignette

Vignette + color, you can change the color and the alpha of the effect.

You can use this in fullscreen with a TextureRect node.
[!] But don’t forget to add a full white bitmap (or other bitmap 🙂 ) in TextureRect.

Enjoy.

Shader code
shader_type canvas_item;

uniform float vignette_intensity = 0.4;
uniform float vignette_opacity : hint_range(0.0, 1.0) = 0.5;
uniform vec4 vignette_rgb : hint_color = vec4(0.0, 0.0, 0.0, 1.0);

float vignette(vec2 uv){
	uv *= 1.0 - uv.xy;
	float vignette = uv.x * uv.y * 15.0;
	return pow(vignette, vignette_intensity * vignette_opacity);
}

void fragment(){
	vec4 color = texture(SCREEN_TEXTURE, SCREEN_UV);
	vec4 text = texture(TEXTURE, UV);
	
	text.rgba *= (vignette_rgb.rgba);
	text.rgba *= (1.0 - vignette(UV));
	
	COLOR = vec4((text.rgb)*color.rgb,text.a);
}
Tags
Color, vignette, Vignetting
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 randomDam

Color manipulator

Related shaders

Vignette with reduced banding artifacts

Chromatic Aberration Vignette

Aberration Vignette – Phasmophobia effect

Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
EliasGD
11 months ago

Hi, @EliasGD here!

Godot 4.1 code update. To use this shader code, just add a white ColorRect – Full Rect, and add a new ShaderMaterial with the following code:

shader_type canvas_item;

uniform float vignette_intensity = 0.4;
uniform float vignette_opacity : hint_range(0.0, 1.0) = 0.5;
uniform vec4 vignette_rgb : source_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;

float vignette(vec2 uv){
uv *= 1.0 – uv.xy;
float vignette = uv.x * uv.y * 15.0;
return pow(vignette, vignette_intensity * vignette_opacity);
}

void fragment(){
vec4 color = texture(SCREEN_TEXTURE, SCREEN_UV);
vec4 text = texture(TEXTURE, UV);
text.rgba *= (vignette_rgb.rgba);
text.rgba *= (1.0 – vignette(UV));
COLOR = vec4((text.rgb)*color.rgb,text.a);
}

Last edited 11 months ago by EliasGD
EliasGD
11 months ago
Reply to  EliasGD
I cant update the comment
Just replace – with - 
Night_Owl
Night_Owl
2 months ago
Reply to  EliasGD

Thank you. It works nicely.