Add color correction to the gles shader

This commit is contained in:
Martijn Braam
2023-07-26 23:40:51 +02:00
parent 10103a2834
commit d13cdd5dcb
7 changed files with 143 additions and 86 deletions

View File

@@ -5,6 +5,7 @@ precision highp float;
uniform sampler2D texture;
uniform mat3 color_matrix;
uniform float inv_gamma;
uniform float blacklevel;
#ifdef BITS_10
uniform float row_length;
uniform float padding_ratio;
@@ -59,16 +60,9 @@ main()
vec3 color = vec3(samples.x, (samples.y + samples.z) / 2.0, samples.w);
#endif
// Some crude blacklevel correction to make the preview a bit nicer, this
// should be an uniform
vec3 corrected = color - 0.02;
/*
// Fast SRGB estimate. See https://mimosa-pudica.net/fast-gamma/
vec3 gamma_color =
(vec3(1.138) * inversesqrt(corrected) - vec3(0.138)) * corrected;
*/
color = color * color_matrix;
color -= blacklevel;
color *= 1.0-(1.0/blacklevel);
color *= color_matrix;
vec3 gamma_color = pow(color, vec3(inv_gamma));
gl_FragColor = vec4(gamma_color, 1);