[vlc-commits] direct3d11_shaders: fix negative pixel colours artefacts

Steve Lhomme git at videolan.org
Mon Oct 15 10:28:36 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Oct 15 09:42:25 2018 +0200| [04d48fefd78e0e170c9937677abc24d7cb43ff33] | committer: Steve Lhomme

direct3d11_shaders: fix negative pixel colours artefacts

It can happens when tone mapping on "LG NASA HDR Demo".

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=04d48fefd78e0e170c9937677abc24d7cb43ff33
---

 modules/video_output/win32/d3d11_shaders.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index 9ad845eb41..9fea7806d6 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -98,7 +98,6 @@ static const char* globPixelShaderDefault = "\
   }\n\
   \n\
   inline float3 linearToDisplay(float3 rgb) {\n\
-     rgb = clamp(rgb, 0, 1);\n\
       %s;\n\
   }\n\
   \n\
@@ -438,7 +437,7 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
                 /* ST2084 to Linear */
                 psz_src_transform =
                        ST2084_PQ_CONSTANTS
-                       "rgb = pow(rgb, 1.0/ST2084_m2);\n"
+                       "rgb = pow(max(rgb, 0), 1.0/ST2084_m2);\n"
                        "rgb = max(rgb - ST2084_c1, 0.0) / (ST2084_c2 - ST2084_c3 * rgb);\n"
                        "rgb = pow(rgb, 1.0/ST2084_m1);\n"
                        "return rgb";
@@ -514,7 +513,7 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
     }
 
     if (display->colorspace->primaries != primaries)
-        psz_primaries_transform = "return mul(rgb, Primaries)";
+        psz_primaries_transform = "return max(mul(rgb, Primaries), 0)";
 
     int range_adjust = 0;
     if (display->colorspace->b_full_range) {



More information about the vlc-commits mailing list