1
0
Fork 0
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:
x2048 2022-11-02 09:09:48 +01:00 committed by GitHub
parent fb3085a2c5
commit 9b24041394
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 195 additions and 59 deletions

View file

@ -0,0 +1,35 @@
#define current texture0
#define previous texture1
uniform sampler2D current;
uniform sampler2D previous;
uniform vec2 texelSize0;
uniform mediump float bloomRadius;
#ifdef GL_ES
varying mediump vec2 varTexCoord;
#else
centroid varying vec2 varTexCoord;
#endif
void main(void)
{
vec2 offset = bloomRadius * texelSize0;
vec3 a = texture2D(previous, varTexCoord.st + vec2(-1., -1.) * offset).rgb;
vec3 b = texture2D(previous, varTexCoord.st + vec2(0., -1.) * offset).rgb;
vec3 c = texture2D(previous, varTexCoord.st + vec2(1., -1.) * offset).rgb;
vec3 d = texture2D(previous, varTexCoord.st + vec2(-1., 0.) * offset).rgb;
vec3 e = texture2D(previous, varTexCoord.st + vec2(0., 0.) * offset).rgb;
vec3 f = texture2D(previous, varTexCoord.st + vec2(1., 0.) * offset).rgb;
vec3 g = texture2D(previous, varTexCoord.st + vec2(-1., 1.) * offset).rgb;
vec3 h = texture2D(previous, varTexCoord.st + vec2(0., 1.) * offset).rgb;
vec3 i = texture2D(previous, varTexCoord.st + vec2(1., 1.) * offset).rgb;
vec3 base = texture2D(current, varTexCoord.st).rgb;
gl_FragColor = max(vec4(base +
(a + c + g + i) * 0.0625 +
(b + d + f + h) * 0.125 +
e * 0.25, 1.), 1e-4);
}

View file

@ -0,0 +1,11 @@
#ifdef GL_ES
varying mediump vec2 varTexCoord;
#else
centroid varying vec2 varTexCoord;
#endif
void main(void)
{
varTexCoord.st = inTexCoord0.st;
gl_Position = inVertexPosition;
}