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.
This commit is contained in:
Xaver Hugl 2024-08-26 23:28:15 +02:00
parent b708a93c1e
commit 587afb3076
2 changed files with 2 additions and 2 deletions

View file

@ -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;
}

View file

@ -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