legacyColorCurves.fx 887 B

123456789101112131415161718
  1. const vec3 HDTVRec709_RGBLuminanceCoefficients = vec3(0.2126, 0.7152, 0.0722);
  2. vec3 applyColorCurves(vec3 original) {
  3. vec3 result = original;
  4. // Apply colour grading curves: luma-based adjustments for saturation, exposure and white balance (color filter)
  5. // Note: the luma-based ramp is calibrated so that at 50% luma the midtone adjustment is full active, and the shadow/highlight
  6. // adjustments are fully active by 16% and 83% luma, respectively.
  7. float luma = dot(result.rgb, HDTVRec709_RGBLuminanceCoefficients);
  8. vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0, 0.0), vec2(1.0, 1.0));
  9. vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative;
  10. result.rgb *= colorCurve.rgb;
  11. result.rgb = mix(vec3(luma, luma, luma), result.rgb, colorCurve.a);
  12. return result;
  13. }