Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d4a1f82 authored by Alec Mouri's avatar Alec Mouri
Browse files

Remove Hermitian tone-mapping curve for HLG

Applying the HLG OOTF as recommended in BT2100 is good enough.

Additionally, fix applying the HLG OOTF to correctly scale to display
brightness. Previously it was scaling to 1000 nits, but renormalize to
[0, 1] assuming a display brightness of 500 nits, which incorrectly
increases luminance.

The net result is that the tone-mapping curve for thumbnails more closely matches the tone-mapping curve used by the default libtonemap implementation used by both display and TextureView, which also just applies the HLG OOTF.

Bug: 232200455
Test: Photos transitions
Change-Id: I03ce481c2f5e47538d1a21f3b6864f61c5a9d9b3
parent b9bd42e6
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -299,8 +299,8 @@ void ProgramCache::generateToneMappingProcess(Formatter& fs, const Key& needs) {
                highp vec3 ScaleLuminance(highp vec3 color) {
                    // The formula is:
                    // alpha * pow(Y, gamma - 1.0) * color + beta;
                    // where alpha is 1000.0, gamma is 1.2, beta is 0.0.
                    return color * 1000.0 * pow(color.y, 0.2);
                    // where alpha is displayMaxLuminance, gamma is 1.2, beta is 0.0.
                    return color * displayMaxLuminance * pow(color.y, 0.2);
                }
            )__SHADER__";
            break;
@@ -316,7 +316,6 @@ void ProgramCache::generateToneMappingProcess(Formatter& fs, const Key& needs) {
    // Tone map absolute light to display luminance range.
    switch (needs.getInputTF()) {
        case Key::INPUT_TF_ST2084:
        case Key::INPUT_TF_HLG:
            switch (needs.getOutputTF()) {
                case Key::OUTPUT_TF_HLG:
                    // Right now when mixed PQ and HLG contents are presented,
@@ -396,6 +395,14 @@ void ProgramCache::generateToneMappingProcess(Formatter& fs, const Key& needs) {
                    break;
            }
            break;
        case Key::INPUT_TF_HLG:
            // HLG OOTF is already applied as part of ScaleLuminance
            fs << R"__SHADER__(
                 highp vec3 ToneMap(highp vec3 color) {
                     return color;
                 }
             )__SHADER__";
            break;
        default:
            // inverse tone map; the output luminance can be up to maxOutLumi.
            fs << R"__SHADER__(