Merge pull request #242 from R0STUS/patch-2

Vignette effect to screen
This commit is contained in:
MihailRis 2024-06-13 23:34:35 +03:00 committed by GitHub
commit 63c2a4e5ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,8 +2,25 @@ in vec2 v_coord;
out vec4 f_color;
uniform sampler2D u_texture0;
uniform ivec2 u_screenSize;
// Vignette
vec4 apply_vignette(vec4 color)
{
vec2 position = (gl_FragCoord.xy / u_screenSize) - vec2(0.5);
float dist = length(position);
float radius = 2.0;
float softness = 1.7;
float vignette = smoothstep(radius, radius - softness, dist);
color.rgb = color.rgb - (1.0 - vignette);
return color;
}
void main(){
f_color = texture(u_texture0, v_coord);
f_color = apply_vignette(f_color);
}