mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-31 18:31:04 +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
|
@ -2,7 +2,7 @@
|
|||
|
||||
uniform sampler2D rendered;
|
||||
uniform mediump float exposureFactor;
|
||||
uniform float bloomLuminanceThreshold;
|
||||
uniform mediump float bloomStrength;
|
||||
|
||||
#ifdef GL_ES
|
||||
varying mediump vec2 varTexCoord;
|
||||
|
@ -14,8 +14,14 @@ centroid varying vec2 varTexCoord;
|
|||
void main(void)
|
||||
{
|
||||
vec2 uv = varTexCoord.st;
|
||||
vec4 color = texture2D(rendered, uv).rgba;
|
||||
vec3 color = texture2D(rendered, uv).rgb;
|
||||
// translate to linear colorspace (approximate)
|
||||
color.rgb = pow(color.rgb, vec3(2.2)) * exposureFactor;
|
||||
gl_FragColor = vec4(color.rgb, 1.0); // force full alpha to avoid holes in the image.
|
||||
color = pow(color, vec3(2.2));
|
||||
|
||||
// Scale colors by luminance to amplify bright colors
|
||||
// in SDR textures.
|
||||
float luminance = dot(color, vec3(0.213, 0.515, 0.072));
|
||||
luminance *= luminance;
|
||||
color *= luminance * exposureFactor * bloomStrength;
|
||||
gl_FragColor = vec4(color, 1.0); // force full alpha to avoid holes in the image.
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue