From a82bbb416f84461172224ac33d59d281668e17e0 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Mon, 25 Apr 2022 09:02:08 -0700 Subject: [PATCH] libobs: Fix NaNs when using EETF for HLG --- libobs/data/color.effect | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libobs/data/color.effect b/libobs/data/color.effect index 04ac022ce..2c6bc3a62 100644 --- a/libobs/data/color.effect +++ b/libobs/data/color.effect @@ -97,12 +97,11 @@ float3 maxRGB_eetf(float3 rgb, float Lw, float Lmax) float maxRGB1_pq = linear_to_st2084_channel(maxRGB_linear); float maxRGB2_pq = eetf_0_1000(Lw, maxRGB1_pq); float maxRGB2_linear = st2084_to_linear_channel(maxRGB2_pq); - float scaling_ratio = maxRGB2_linear / maxRGB_linear; - // scaling_ratio could be NaN - scaling_ratio = max(0., scaling_ratio); + // avoid divide-by-zero possibility + maxRGB_linear = max(6.10352e-5, maxRGB_linear); - rgb *= scaling_ratio; + rgb *= maxRGB2_linear / maxRGB_linear; return rgb; }