2022-09-29 20:34:05 +02:00
|
|
|
#define rendered texture0
|
|
|
|
|
|
|
|
uniform sampler2D rendered;
|
2022-10-04 14:52:56 +02:00
|
|
|
uniform mediump float exposureFactor;
|
2022-11-02 09:09:48 +01:00
|
|
|
uniform mediump float bloomStrength;
|
2022-09-29 20:34:05 +02:00
|
|
|
|
|
|
|
#ifdef GL_ES
|
|
|
|
varying mediump vec2 varTexCoord;
|
|
|
|
#else
|
|
|
|
centroid varying vec2 varTexCoord;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
2022-11-02 09:09:48 +01:00
|
|
|
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.
|
2022-09-29 20:34:05 +02:00
|
|
|
}
|