summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippo Tarpini <filippotarpini@hotmail.it>2023-09-09 18:12:47 +0300
committerGitHub <noreply@github.com>2023-09-09 18:12:47 +0300
commit84c8eb5a015074541caef02590f7c21bcf425bcf (patch)
tree03e69ed5fb5477b6326da33c4fba526515324658
parent5e0cf795e3dbda66e4b53b2264cc163c986cb7b0 (diff)
Make AutoHDR work with color luminance instead of average
This gives more consistent results. My main ReShade has also been updated with the same change: https://github.com/Filoppi/PumboAutoHDR
-rw-r--r--Data/Sys/Shaders/AutoHDR.glsl11
1 files changed, 8 insertions, 3 deletions
diff --git a/Data/Sys/Shaders/AutoHDR.glsl b/Data/Sys/Shaders/AutoHDR.glsl
index 6226d70d7c..b806d65838 100644
--- a/Data/Sys/Shaders/AutoHDR.glsl
+++ b/Data/Sys/Shaders/AutoHDR.glsl
@@ -30,6 +30,11 @@ DefaultValue = 2.5
[/configuration]
*/
+float luminance(float3 color)
+{
+ return dot(color, float3(0.2126f, 0.7152f, 0.0722f));
+}
+
void main()
{
float4 color = Sample();
@@ -46,8 +51,8 @@ void main()
// Restore the original SDR (0-1) brightness (we might or might not restore it later)
color.rgb /= hdr_paper_white;
- // Find the color average
- float sdr_ratio = (color.r + color.g + color.b) / 3.0;
+ // Find the color luminance (it works better than average)
+ float sdr_ratio = luminance(color.rgb);
const float auto_hdr_max_white = max(HDR_DISPLAY_MAX_NITS / (hdr_paper_white_nits / hdr_sdr_white_nits), hdr_sdr_white_nits) / hdr_sdr_white_nits;
if (sdr_ratio > AUTO_HDR_SHOULDER_START_ALPHA && AUTO_HDR_SHOULDER_START_ALPHA < 1.0)
@@ -61,4 +66,4 @@ void main()
color.rgb *= hdr_paper_white;
SetOutput(color);
-} \ No newline at end of file
+}