vec4 x = INPUT(tc);
x.rgb /= x.aaa;
+
+ // pow() of negative numbers is undefined, so clip out-of-gamut values.
+ x.rgb = max(x.rgb, 0.0);
+
x.rgb = pow(x.rgb, vec3(1.0/2.2));
x.rgb += PREFIX(lift) * (vec3(1) - x.rgb);
x.rgb = pow(x.rgb, PREFIX(inv_gamma_22));