Skip to content

Instantly share code, notes, and snippets.

@Pyromuffin
Last active July 6, 2018 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pyromuffin/5fff39dd5ea2c977e88f6fee3019f92f to your computer and use it in GitHub Desktop.
Save Pyromuffin/5fff39dd5ea2c977e88f6fee3019f92f to your computer and use it in GitHub Desktop.
float3 ApplyREC2084Curve(float3 L, float maxLuminance)
{
float m1 = 2610.0 / 4096.0 / 4;
float m2 = 2523.0 / 4096.0 * 128;
float c1 = 3424.0 / 4096.0;
float c2 = 2413.0 / 4096.0 * 32;
float c3 = 2392.0 / 4096.0 * 32;
// L = FD / 10000, so if FD == 10000, then L = 1.
// so to scale max luminance, we want to multiply by maxLuminance / 10000
float maxLuminanceScale = maxLuminance / 10000.0f;
L *= maxLuminanceScale;
float3 Lp = pow(L, m1);
return pow((c1 + c2 * Lp) / (1 + c3 * Lp), m2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment