bloomblur.frag

Input Variables

Texture coord and the framebuffer texture for blurring

in vec2 texCoord;
layout (binding=2)  uniform sampler2D texblur;

Weight for one dimensional Gaussian blurring

weight[0] is the weight for the current pixel, weight[i] for its left i and right i pixel respectively.

uniform float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);

pass

We are going to iteratively apply the horizaontal and vertical blurring, so we need a pass number.

If the pass is odd, we think it is a horizontal blurring, otherwise a vertcal.

uniform int pass;

Output variables

We only need the output fragment colour.

out vec4 colour_out;

main()

Get the pixel colour from previous iteration (filtering or blurring)

Get the size of a single texel

Horizontal blurring

If the pass number is odd, we are going to perform a horizontal blurring by weighted averaging.

Vertical blurring

If the pass number is even, we are going to perform a horizontal blurring by weighted averaging.

Finally return the fragment colour

Full Source Code

Last updated