]> git.sesse.net Git - movit/blob - lift_gamma_gain_effect.frag
Make the ResourcePool hold FBOs as a per-context resource.
[movit] / lift_gamma_gain_effect.frag
1 // These are calculated in the host code to save some arithmetic.
2 uniform vec3 PREFIX(gain_pow_inv_gamma);  // gain^(1/gamma).
3 uniform vec3 PREFIX(inv_gamma_22);  // 2.2 / gamma.
4
5 vec4 FUNCNAME(vec2 tc) {
6         vec4 x = INPUT(tc);
7
8         x.rgb /= x.aaa;
9
10         // pow() of negative numbers is undefined, so clip out-of-gamut values.
11         x.rgb = max(x.rgb, 0.0);
12
13         x.rgb = pow(x.rgb, vec3(1.0/2.2));
14         x.rgb += PREFIX(lift) * (vec3(1) - x.rgb);
15         x.rgb = pow(x.rgb, PREFIX(inv_gamma_22));
16         x.rgb *= PREFIX(gain_pow_inv_gamma);
17         x.rgb *= x.aaa;
18
19         return x;
20 }