Last active
July 6, 2018 20:25
-
-
Save Pyromuffin/5fff39dd5ea2c977e88f6fee3019f92f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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