minetest/client/shaders/extract_bloom/opengl_fragment.glsl
x2048 6d45c243f8
Add dynamic exposure correction (#12959)
* Add uniform for frame delta time
* Adjust exposure in logarithmic (EV) space
* Add network support and LUA API
* Add testing mod
2023-01-06 22:33:25 +01:00

29 lines
644 B
GLSL

#define rendered texture0
struct ExposureParams {
float compensationFactor;
};
uniform sampler2D rendered;
uniform mediump float bloomStrength;
uniform ExposureParams exposureParams;
#ifdef GL_ES
varying mediump vec2 varTexCoord;
#else
centroid varying vec2 varTexCoord;
#endif
varying float exposure;
void main(void)
{
vec2 uv = varTexCoord.st;
vec3 color = texture2D(rendered, uv).rgb;
// translate to linear colorspace (approximate)
color = pow(color, vec3(2.2));
color *= pow(2., exposure) * exposureParams.compensationFactor * bloomStrength;
gl_FragColor = vec4(color, 1.0); // force full alpha to avoid holes in the image.
}