Hello programmers,
I wish to add a vignette effect to the screen.
My fragment shader -
varying vec4 vColor;
varying vec2 vTexCoord;
uniform vec2 screenSize;
uniform sampler2D u_texture;
uniform vec4 gameTime;
const float RADIUS = 0.75;
const float SOFTNESS = 0.6;
void main() {
vec4 texColor = texture2D(u_texture, vTexCoord);
vec4 timedColor = (vColor + gameTime);
vec2 position = (gl_FragCoord.xy / screenSize.xy) - vec2(0.5);
float len = length(position);
float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);
texColor.rgb = mix(texColor.rgb, texColor.rgb * vignette, 0.5);
gl_FragColor = vec4(texColor.rgb * timedColor.rgb, texColor.a);
}
the code above, adds the vignette effect only to a texture.
but i want it to add the vignette effect to the whole screen.
I thought may be i should add a transparent background image with the vignette effect on top of everything.
What do you think? what is the best way to implement this in GLSL?
Thanks bros