2022-09-29 20:34:05 +02:00
|
|
|
#define rendered texture0
|
|
|
|
|
2023-01-06 22:33:25 +01:00
|
|
|
struct ExposureParams {
|
|
|
|
float compensationFactor;
|
|
|
|
};
|
|
|
|
|
2022-09-29 20:34:05 +02:00
|
|
|
uniform sampler2D rendered;
|
2022-11-02 09:09:48 +01:00
|
|
|
uniform mediump float bloomStrength;
|
2023-01-06 22:33:25 +01:00
|
|
|
uniform ExposureParams exposureParams;
|
2022-09-29 20:34:05 +02:00
|
|
|
|
|
|
|
#ifdef GL_ES
|
|
|
|
varying mediump vec2 varTexCoord;
|
|
|
|
#else
|
|
|
|
centroid varying vec2 varTexCoord;
|
|
|
|
#endif
|
|
|
|
|
2023-02-10 21:04:37 +01:00
|
|
|
#ifdef ENABLE_AUTO_EXPOSURE
|
|
|
|
varying float exposure; // linear exposure factor, see vertex shader
|
|
|
|
#endif
|
2022-09-29 20:34:05 +02:00
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
vec2 uv = varTexCoord.st;
|
2022-11-02 09:09:48 +01:00
|
|
|
vec3 color = texture2D(rendered, uv).rgb;
|
2022-09-29 20:34:05 +02:00
|
|
|
// translate to linear colorspace (approximate)
|
2024-11-25 20:56:32 +01:00
|
|
|
color = pow(clamp(color, 0.0, 1.0), vec3(2.2));
|
2022-11-02 09:09:48 +01:00
|
|
|
|
2023-02-10 21:04:37 +01:00
|
|
|
color *= exposureParams.compensationFactor * bloomStrength;
|
|
|
|
|
|
|
|
#ifdef ENABLE_AUTO_EXPOSURE
|
|
|
|
color *= exposure;
|
|
|
|
#endif
|
|
|
|
|
2022-11-02 09:09:48 +01:00
|
|
|
gl_FragColor = vec4(color, 1.0); // force full alpha to avoid holes in the image.
|
2022-09-29 20:34:05 +02:00
|
|
|
}
|