bloomfilter.frag
Create bloomfilter.frag under the shaders directory.
Input variables
We only need the texture coordinate and the texture itself.
in vec2 texCoord;
// render-to-texture of the scene generated in the 1st pass
layout (binding=1) uniform sampler2D renderTex;Scene rendering as a texture
From this shader, we start to use the 430 texture binding:
// render-to-texture of the scene generated in the 1st pass
layout (binding=1) uniform sampler2D renderTex;With this binding setting, you no longer need to set the texture unit with glUniform().
Output variables
The only output variable we need is the ouput fragment colour.
out vec4 colour_out;main()
Read the pixel colour of the scene
First, read the pixel colour from the scene texture:
Calculate the brightness
We are calculating the brightness of a pixel based on the following RGB coefficients:
Filtering
In this fragment shader, we simply use a brightness threshold.
The following is an example using a thresholdof 0.9
Full Source Code
Last updated