2022-09-29 20:34:05 +02:00
|
|
|
#define rendered texture0
|
|
|
|
|
|
|
|
uniform sampler2D rendered;
|
|
|
|
uniform vec2 texelSize0;
|
2022-10-04 14:52:56 +02:00
|
|
|
uniform mediump float bloomRadius;
|
2022-11-02 09:09:48 +01:00
|
|
|
uniform mat3 bloomBlurWeights;
|
2022-09-29 20:34:05 +02:00
|
|
|
|
|
|
|
#ifdef GL_ES
|
|
|
|
varying mediump vec2 varTexCoord;
|
|
|
|
#else
|
|
|
|
centroid varying vec2 varTexCoord;
|
|
|
|
#endif
|
|
|
|
|
2022-11-02 09:09:48 +01:00
|
|
|
// smoothstep - squared
|
|
|
|
float smstsq(float f)
|
|
|
|
{
|
2024-01-16 21:09:18 +01:00
|
|
|
f = f * f * (3. - 2. * f);
|
2022-11-02 09:09:48 +01:00
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
2022-09-29 20:34:05 +02:00
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
// kernel distance and linear size
|
|
|
|
mediump float n = 2. * bloomRadius + 1.;
|
|
|
|
|
|
|
|
vec2 uv = varTexCoord.st - vec2(bloomRadius * texelSize0.x, 0.);
|
|
|
|
vec4 color = vec4(0.);
|
|
|
|
mediump float sum = 0.;
|
|
|
|
for (mediump float i = 0.; i < n; i++) {
|
2022-11-02 09:09:48 +01:00
|
|
|
mediump float weight = smstsq(1. - (abs(i / bloomRadius - 1.)));
|
|
|
|
color.rgb += texture2D(rendered, uv).rgb * weight;
|
2022-09-29 20:34:05 +02:00
|
|
|
sum += weight;
|
|
|
|
uv += vec2(texelSize0.x, 0.);
|
|
|
|
}
|
|
|
|
color /= sum;
|
|
|
|
gl_FragColor = vec4(color.rgb, 1.0); // force full alpha to avoid holes in the image.
|
|
|
|
}
|