mirror of
https://github.com/minetest/minetest.git
synced 2024-12-25 07:32:24 +01:00
9b24041394
* Remove the built-in exposure factor of 2.5 * Add physics-based bloom (https://learnopengl.com/Guest-Articles/2022/Phys.-Based-Bloom) * Add luminance scaling for bloom layer to simulate HDR * Add setting to control bloom strength
38 lines
861 B
GLSL
38 lines
861 B
GLSL
#define rendered texture0
|
|
|
|
uniform sampler2D rendered;
|
|
uniform vec2 texelSize0;
|
|
uniform mediump float bloomRadius;
|
|
uniform mat3 bloomBlurWeights;
|
|
|
|
#ifdef GL_ES
|
|
varying mediump vec2 varTexCoord;
|
|
#else
|
|
centroid varying vec2 varTexCoord;
|
|
#endif
|
|
|
|
// smoothstep - squared
|
|
float smstsq(float f)
|
|
{
|
|
f = f * f * (3 - 2 * f);
|
|
return f;
|
|
}
|
|
|
|
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++) {
|
|
mediump float weight = smstsq(1. - (abs(i / bloomRadius - 1.)));
|
|
color.rgb += texture2D(rendered, uv).rgb * weight;
|
|
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.
|
|
}
|