Vignette Shader for godot 4 :)

make a colorrect and add a material, then a sahder material. and it should work!

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 : source_color = vec4(0.0, 0.0, 0.0, 1.0);

uniform sampler2D screen_vec : hint_screen_texture;

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_vec, 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);
}
Live Preview
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

Blur Vignette (Post Processing / ColorRect) [Godot 4.2.1]

Camera Vignette Shader

Chromatic Aberration Vignette

guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Zyrean
Zyrean
1 year ago

Thanks!

denis23x
11 months ago

Hi 👋 I used this shader for my first Godot game! Please check it out

https://denis23x.itch.io/deepwood 

I’ve linked you in the game description, in the game itself and in the game repository, thanks for the materials you provided 🙏

https://github.com/denis23x/deepwood