Fix an issue where a (cached) shader program could be used from multiple
[movit] / lift_gamma_gain_effect.frag
1 // Implicit uniforms:
2 //
3 // These are calculated in the host code to save some arithmetic.
4 // uniform vec3 PREFIX(gain_pow_inv_gamma);  // gain^(1/gamma).
5 // uniform vec3 PREFIX(inv_gamma_22);  // 2.2 / gamma.
6
7 vec4 FUNCNAME(vec2 tc) {
8         vec4 x = INPUT(tc);
9
10         x.rgb /= x.aaa;
11
12         // pow() of negative numbers is undefined, so clip out-of-gamut values.
13         x.rgb = max(x.rgb, 0.0);
14
15         x.rgb = pow(x.rgb, vec3(1.0/2.2));
16         x.rgb += PREFIX(lift) * (vec3(1) - x.rgb);
17         x.rgb = pow(x.rgb, PREFIX(inv_gamma_22));
18         x.rgb *= PREFIX(gain_pow_inv_gamma);
19         x.rgb *= x.aaa;
20
21         return x;
22 }