Skip to content

Commit 7362168

Browse files
committed
cEnsor: Added color mode, cImageSharpening: Added mask mode
1 parent 67bc585 commit 7362168

File tree

3 files changed

+48
-27
lines changed

3 files changed

+48
-27
lines changed

shaders/cEnsor.fx

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,30 @@ namespace cEnsor
1111
ui_max = 7;
1212
> = 3;
1313

14-
uniform float _Threshold <
15-
ui_label = "Search Threshold";
16-
ui_type = "slider";
17-
ui_min = 0.0;
18-
ui_max = 1.0;
19-
> = 0.1;
20-
21-
uniform int _Select <
22-
ui_label = "Search Feature";
14+
uniform int _DetectionMode <
15+
ui_label = "Search Mode";
2316
ui_type = "combo";
24-
ui_items = "HSV: Hue\0HSV: Saturation\0HSV: Value\0HSL: Hue\0HSL: Saturation\0HSL: Lightness\0HSI: Hue\0HSI: Saturation\0HSI: Intensity\0";
25-
> = 2;
17+
ui_items = "Color\0\HSV: Hue\0HSV: Saturation\0HSV: Value\0HSL: Hue\0HSL: Saturation\0HSL: Lightness\0HSI: Hue\0HSI: Saturation\0HSI: Intensity\0";
18+
> = 0;
2619

2720
uniform int _Comparison <
2821
ui_label = "Search Operator";
2922
ui_type = "combo";
30-
ui_items = "Less Than\0Greater Than\0Equal\0Not Equal\0Less Than of Equal\0Greater Than or Equal\0";
23+
ui_items = "Less Than\0Greater Than\0Equal\0Not Equal\0Less Than or Equal\0Greater Than or Equal\0";
3124
> = 1;
3225

33-
uniform bool _DisplayMask <
34-
ui_label = "Display Mask";
26+
uniform float _Threshold <
27+
ui_label = "Search Threshold";
28+
ui_type = "slider";
29+
ui_min = 0.0;
30+
ui_max = 1.0;
31+
> = 0.1;
32+
33+
uniform int _DisplayMode <
34+
ui_label = "Display Mode";
3535
ui_type = "radio";
36-
> = false;
36+
ui_items = "Output\0Mask\0";
37+
> = 0;
3738

3839
CREATE_TEXTURE_POOLED(TempTex0_RGBA8, BUFFER_SIZE_0, RGBA8, 8)
3940
CREATE_SRGB_SAMPLER(SampleTempTex0, TempTex0_RGBA8, POINT, MIRROR)
@@ -49,36 +50,39 @@ namespace cEnsor
4950
float4 Pixel = tex2Dlod(SampleTempTex0, float4(Input.Tex0, 0.0, _Blockiness));
5051

5152
// Initialize variables
52-
float Feature = 0.0;
53-
bool Mask = false;
53+
float4 Feature = 0.0;
54+
bool4 Mask = false;
5455

55-
switch(_Select)
56+
switch(_DetectionMode)
5657
{
5758
case 0:
58-
Feature = CColor_GetHSVfromRGB(Pixel.rgb).r;
59+
Feature = Pixel;
5960
break;
6061
case 1:
61-
Feature = CColor_GetHSVfromRGB(Pixel.rgb).g;
62+
Feature = CColor_GetHSVfromRGB(Pixel.rgb).r;
6263
break;
6364
case 2:
64-
Feature = CColor_GetHSVfromRGB(Pixel.rgb).b;
65+
Feature = CColor_GetHSVfromRGB(Pixel.rgb).g;
6566
break;
6667
case 3:
67-
Feature = CColor_GetHSLfromRGB(Pixel.rgb).r;
68+
Feature = CColor_GetHSVfromRGB(Pixel.rgb).b;
6869
break;
6970
case 4:
70-
Feature = CColor_GetHSLfromRGB(Pixel.rgb).g;
71+
Feature = CColor_GetHSLfromRGB(Pixel.rgb).r;
7172
break;
7273
case 5:
73-
Feature = CColor_GetHSLfromRGB(Pixel.rgb).b;
74+
Feature = CColor_GetHSLfromRGB(Pixel.rgb).g;
7475
break;
7576
case 6:
76-
Feature = CColor_GetHSIfromRGB(Pixel.rgb).r;
77+
Feature = CColor_GetHSLfromRGB(Pixel.rgb).b;
7778
break;
7879
case 7:
79-
Feature = CColor_GetHSIfromRGB(Pixel.rgb).g;
80+
Feature = CColor_GetHSIfromRGB(Pixel.rgb).r;
8081
break;
8182
case 8:
83+
Feature = CColor_GetHSIfromRGB(Pixel.rgb).g;
84+
break;
85+
case 9:
8286
Feature = CColor_GetHSIfromRGB(Pixel.rgb).b;
8387
break;
8488
default:
@@ -108,7 +112,7 @@ namespace cEnsor
108112
break;
109113
}
110114

111-
if(_DisplayMask)
115+
if (_DisplayMode == 1)
112116
{
113117
return Mask;
114118
}

shaders/cImageSharpening.fx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,31 @@ uniform float _Sharpening <
5656
ui_max = 1.0;
5757
> = 1.0;
5858

59+
uniform int _DisplayMode <
60+
ui_label = "Display Mode";
61+
ui_type = "radio";
62+
ui_items = "Output\0Mask\0";
63+
> = 0;
64+
5965
float4 PS_CasFilterNoScaling(CShade_VS2PS_Quad Input): SV_TARGET0
6066
{
6167
float4 OutputColor = 1.0;
68+
float4 OutputMask = 1.0;
6269
FFX_CAS_FilterNoScaling(
6370
OutputColor,
71+
OutputMask,
6472
Input,
6573
_Detection,
6674
_Kernel,
6775
_Contrast,
6876
_Sharpening
6977
);
78+
79+
if (_DisplayMode == 1)
80+
{
81+
return OutputMask;
82+
}
83+
7084
return OutputColor;
7185
}
7286

shaders/shared/fidelityfx/cCas.fxh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
void FFX_CAS_FilterNoScaling(
3535
inout float4 FilterShape,
36+
out float4 FilterMask,
3637
in CShade_VS2PS_Quad Input,
3738
in int Detection,
3839
in int Kernel,
@@ -134,6 +135,8 @@
134135
FilterShape += Sample[4] * Weight;
135136
FilterShape = saturate(FilterShape * ReciprocalWeight);
136137
FilterShape = lerp(Sample[0], FilterShape, Sharpening);
138+
139+
FilterMask = AmplifyRGB;
137140
}
138141

139142
#endif

0 commit comments

Comments
 (0)