Vignetting
is a reduction of an image's brightness or saturation at the periphery compared
to the image centre.
Pass
1: Render the scene to texture using an
FBO
Pass
2: Render a full-screen quad using the
texture from pass 1 to the default framebuffer.
In the fragment shader,
-
Compute the distance from the centre of
the screen.
- Darken the fragment based on this
distance.
Code below inspired from
Github// some things above omittedvoid
main() {
vec4 texColour = texture(sampler0,
vTexCoord);
vec2 vectorFromCentre = vTexCoord.xy - vec2(0.5);
float
vignette = 1 - smoothstep(0.3,
0.75, length(vectorFromCentre));
texColour.rgb *= vignette;
vOutputColour = texColour;}