From 19d3a69f6f8e56a1686b3db003673453f421cc84 Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 7 Feb 2022 00:30:53 -0700 Subject: [PATCH] Update normalization minima --- shaders/cColorNormalization.fx | 11 ++++++----- shaders/cHornSchunck.fx | 3 ++- shaders/cInterpolation.fx | 3 ++- shaders/cMotionBlur.fx | 3 ++- shaders/cOpticalFlow.fx | 3 ++- shaders/kDatamosh.fx | 3 ++- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/shaders/cColorNormalization.fx b/shaders/cColorNormalization.fx index debbdb9..8fb553c 100644 --- a/shaders/cColorNormalization.fx +++ b/shaders/cColorNormalization.fx @@ -66,7 +66,7 @@ void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, /* Sources - Angle-Retaining Chromaticity + Angle-Retaining Chromaticity Copyright 2020 Marco Buzzelli, Simone Bianco, Raimondo Schettini. If you use this code in your research, please cite: @article{buzzelli2020arc, @@ -91,8 +91,9 @@ void PostProcessVS(in uint ID : SV_VertexID, out float4 Position : SV_Position, void NormalizationPS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float3 OutputColor0 : SV_Target0) { - OutputColor0 = 0.0; - float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, 1e-7); + OutputColor0 = 0.0; + const float Minima = ldexp(1.0, -8.0); + float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, Minima); switch(_Select) { case 0: @@ -113,8 +114,8 @@ void NormalizationPS(in float4 Position : SV_Position, in float2 TexCoord : TEXC break; case 4: // Jamie Wong's RG Chromaticity - OutputColor0 = Color / dot(Color, 1.0); - OutputColor0.rg = saturate(OutputColor0.rg / max(max(OutputColor0.r, OutputColor0.g), OutputColor0.b)); + float3 NormalizedRGB = Color / dot(Color, 1.0); + OutputColor0.rg = saturate(NormalizedRGB.rg / max(max(NormalizedRGB.r, NormalizedRGB.g), NormalizedRGB.b)); break; case 5: // Jamie Wong's RGB Chromaticity diff --git a/shaders/cHornSchunck.fx b/shaders/cHornSchunck.fx index 0ac6677..d740fdd 100644 --- a/shaders/cHornSchunck.fx +++ b/shaders/cHornSchunck.fx @@ -333,7 +333,8 @@ namespace HornSchunck void NormalizePS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float2 OutputColor0 : SV_Target0) { - float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, 1e-7); + const float Minima = ldexp(1.0, -8.0); + float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, Minima); OutputColor0 = saturate(Color.xy / dot(Color, 1.0)); } diff --git a/shaders/cInterpolation.fx b/shaders/cInterpolation.fx index 2bcc865..6eb15df 100644 --- a/shaders/cInterpolation.fx +++ b/shaders/cInterpolation.fx @@ -541,7 +541,8 @@ namespace Interpolation void NormalizePS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float2 OutputColor0 : SV_Target0) { - float3 Color = max(tex2D(_SampleFrame0, TexCoord).rgb, 1e-7); + const float Minima = ldexp(1.0, -8.0); + float3 Color = max(tex2D(_SampleFrame0, TexCoord).rgb, Minima); OutputColor0 = saturate(Color.xy / dot(Color, 1.0)); } diff --git a/shaders/cMotionBlur.fx b/shaders/cMotionBlur.fx index 8fa9537..68292e2 100644 --- a/shaders/cMotionBlur.fx +++ b/shaders/cMotionBlur.fx @@ -519,7 +519,8 @@ namespace MotionBlur void NormalizePS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float2 OutputColor0 : SV_Target0) { - float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, 1e-7); + const float Minima = ldexp(1.0, -8.0); + float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, Minima); OutputColor0 = saturate(Color.xy / dot(Color, 1.0)); } diff --git a/shaders/cOpticalFlow.fx b/shaders/cOpticalFlow.fx index 065e879..390bc6c 100644 --- a/shaders/cOpticalFlow.fx +++ b/shaders/cOpticalFlow.fx @@ -628,7 +628,8 @@ namespace OpticalFlow void NormalizePS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float2 OutputColor0 : SV_Target0) { - float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, 1e-7); + const float Minima = ldexp(1.0, -8.0); + float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, Minima); OutputColor0 = saturate(Color.xy / dot(Color, 1.0)); } diff --git a/shaders/kDatamosh.fx b/shaders/kDatamosh.fx index a983460..8086173 100644 --- a/shaders/kDatamosh.fx +++ b/shaders/kDatamosh.fx @@ -257,7 +257,8 @@ namespace DataMosh void ConvertPS(in float4 Position : SV_Position, in float2 TexCoord : TEXCOORD0, out float2 OutputColor0 : SV_Target0) { - float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, 1e-7); + const float Minima = ldexp(1.0, -8.0); + float3 Color = max(tex2D(_SampleColor, TexCoord).rgb, Minima); OutputColor0 = saturate(Color.xy / dot(Color, 1.0)); }