mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Improve bloom effect (#12916)
* 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
This commit is contained in:
parent
fb3085a2c5
commit
9b24041394
15 changed files with 195 additions and 59 deletions
|
@ -3,6 +3,7 @@
|
|||
uniform sampler2D rendered;
|
||||
uniform vec2 texelSize0;
|
||||
uniform mediump float bloomRadius;
|
||||
uniform mat3 bloomBlurWeights;
|
||||
|
||||
#ifdef GL_ES
|
||||
varying mediump vec2 varTexCoord;
|
||||
|
@ -10,6 +11,13 @@ varying mediump vec2 varTexCoord;
|
|||
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
|
||||
|
@ -19,8 +27,8 @@ void main(void)
|
|||
vec4 color = vec4(0.);
|
||||
mediump float sum = 0.;
|
||||
for (mediump float i = 0.; i < n; i++) {
|
||||
mediump float weight = pow(1. - (abs(i / bloomRadius - 1.)), 1.3);
|
||||
color += texture2D(rendered, uv).rgba * weight;
|
||||
mediump float weight = smstsq(1. - (abs(i / bloomRadius - 1.)));
|
||||
color.rgb += texture2D(rendered, uv).rgb * weight;
|
||||
sum += weight;
|
||||
uv += vec2(0., texelSize0.y);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue