From 587afb3076a647e2fbf6ed360fa1b0efc33e95fa Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 26 Aug 2024 23:28:15 +0200 Subject: [PATCH] core/colorpipeline: only reduce the reference luminance enough to get 50% headroom If the output side / display can already show at least 50% headroom, dimming the image to get more space for the highlights doesn't improve the highlights a lot, definitely not enough to justify making the rest of the image worse for it. --- src/core/colorpipeline.cpp | 2 +- src/opengl/colormanagement.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/colorpipeline.cpp b/src/core/colorpipeline.cpp index 53032382f9..97b4739c71 100644 --- a/src/core/colorpipeline.cpp +++ b/src/core/colorpipeline.cpp @@ -343,7 +343,7 @@ ColorTonemapper::ColorTonemapper(double referenceLuminance, double maxInputLumin m_inputRange = maxInputLuminance / referenceLuminance; const double outputRange = maxOutputLuminance / referenceLuminance; // = how much dynamic range this algorithm adds, by reducing the reference luminance - m_addedRange = std::clamp(m_inputRange / outputRange, 1.0, maxAddedHeadroom); + m_addedRange = std::min(m_inputRange, std::clamp(maxAddedHeadroom / outputRange, 1.0, maxAddedHeadroom)); m_outputReferenceLuminance = referenceLuminance / m_addedRange; } diff --git a/src/opengl/colormanagement.glsl b/src/opengl/colormanagement.glsl index 08303462cc..fb93524d3a 100644 --- a/src/opengl/colormanagement.glsl +++ b/src/opengl/colormanagement.glsl @@ -117,7 +117,7 @@ vec3 doTonemapping(vec3 color) { // if the reference is too close to the maximum luminance, reduce it to get up to 50% headroom float inputRange = maxTonemappingLuminance / destinationReferenceLuminance; float outputRange = maxDestinationLuminance / destinationReferenceLuminance; - float addedRange = min(inputRange / outputRange, 1.5); + float addedRange = min(inputRange, clamp(1.5 / outputRange, 1.0, 1.5)); float outputReferenceLuminance = destinationReferenceLuminance / addedRange; // keep it linear up to the reference luminance