From 06f86679a3af40add1729585efc0e69e9e1b63e4 Mon Sep 17 00:00:00 2001 From: papadanku <115061077+papadanku@users.noreply.github.com> Date: Fri, 26 Jul 2024 19:43:13 -0700 Subject: [PATCH] cContrastNormalization: Fixed selection --- shaders/cBloom.fx | 2 +- shaders/cContrastNormalization.fx | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/shaders/cBloom.fx b/shaders/cBloom.fx index 6984b54..aed5394 100644 --- a/shaders/cBloom.fx +++ b/shaders/cBloom.fx @@ -174,7 +174,7 @@ float4 PS_Prefilter(CShade_VS2PS_Quad Input) : SV_TARGET0 float LogLuminance = GetLogLuminance(ColorTex.rgb); // Under-threshold - float Brightness = CMath_Med3(Color.r, Color.g, Color.b); + float Brightness = CMath_Med3(Color.r, Color.g, Color.b).r; float Response_Curve = clamp(Brightness - Curve.x, 0.0, Curve.y); Response_Curve = Curve.z * Response_Curve * Response_Curve; diff --git a/shaders/cContrastNormalization.fx b/shaders/cContrastNormalization.fx index abfa77d..87f78c0 100644 --- a/shaders/cContrastNormalization.fx +++ b/shaders/cContrastNormalization.fx @@ -2,6 +2,12 @@ #include "shared/cShade.fxh" #include "shared/cMath.fxh" +uniform int _Select < + ui_label = "Filter"; + ui_type = "combo"; + ui_items = "Local Contrast Normalization\0Census Transform\0"; +> = 0; + /* [Pixel Shaders] */ @@ -58,14 +64,23 @@ float4 GetLocalContrastNormalization(sampler2D Image, float2 Tex) StdDev += (G * G); } - StdDev = sqrt(max(StdDev / 5.0, 1e-4)); + StdDev = sqrt(max(StdDev / 5.0, 1e-6)); return (S[0] - Mean) / StdDev; } float4 PS_ContrastNormalization(CShade_VS2PS_Quad Input) : SV_TARGET0 { - float4 LCN = GetLocalContrastNormalization(CShade_SampleColorTex, Input.Tex0); - return (dot(LCN.rgb, 1.0 / 3.0) * 0.5) + 0.5; + switch (_Select) + { + case 0: + float4 LCN = GetLocalContrastNormalization(CShade_SampleColorTex, Input.Tex0); + return (dot(LCN.rgb, 1.0 / 3.0) * 0.5) + 0.5; + case 1: + float4 CT = GetCensusTransform(CShade_SampleColorTex, Input.Tex0); + return dot(CT.rgb, 1.0 / 3.0); + default: + return 0.5; + } } technique CShade_ContrastNormalization