Skip to content

Commit

Permalink
cContrastNormalization: Fixed selection
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jul 27, 2024
1 parent 8a957ac commit 06f8667
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion shaders/cBloom.fx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
21 changes: 18 additions & 3 deletions shaders/cContrastNormalization.fx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
*/
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 06f8667

Please sign in to comment.