bloomblend.frag

Input variables

The texture coordinate of the full-screen square

in vec2 texCoord;

The scene texture and the blurred highlight texture

layout (binding=1) uniform sampler2D texrender;
layout (binding=2) uniform sampler2D texblur;

Output variables

There is only one output variable: the fragment colour.

out vec4 colour_out;

main()

We are going to blend the the original rendering with the blurred highlights.

Accordingly, we read colour from two corresponding textures, one is the texture of the rendered scene, the other is the texture of the blurred highlights.

    vec3 renderColour = texture(texrender, texCoord).rgb;      
    vec3 bloomColour = texture(texblur, texCoord).rgb;

Additive blending

A simple blending is using addition:

High dyamic range (HDR) blending

But you may see the highlights are washed out because of the pixel values excceed 1.0f:

We can use tone mapping and gamma correction to improve it, as described in https://learnopengl.com/Advanced-Lighting/HDR

Full Source Code

Last updated