mirror of
https://github.com/minetest/minetest.git
synced 2024-12-25 23:47:29 +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
28 lines
696 B
GLSL
28 lines
696 B
GLSL
#define rendered texture0
|
|
|
|
uniform sampler2D rendered;
|
|
uniform mediump float exposureFactor;
|
|
uniform mediump float bloomStrength;
|
|
|
|
#ifdef GL_ES
|
|
varying mediump vec2 varTexCoord;
|
|
#else
|
|
centroid varying vec2 varTexCoord;
|
|
#endif
|
|
|
|
|
|
void main(void)
|
|
{
|
|
vec2 uv = varTexCoord.st;
|
|
vec3 color = texture2D(rendered, uv).rgb;
|
|
// translate to linear colorspace (approximate)
|
|
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.
|
|
}
|