Skip to content

Commit

Permalink
CBlend: Added debug option
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Aug 18, 2024
1 parent 8fab43d commit 198b5a4
Show file tree
Hide file tree
Showing 26 changed files with 85 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CShade features shaders that filter images for aesthetics.
> = 1.0;
```

- In uniforms stored in `.fxh` header files, wrap `[ ]` around `ui_category`/`ui_label`
- In uniforms stored in `.fxh` header files, wrap `[ ]` around `ui_category`

```md
uniform float _CShadeExposureSmoothingSpeed <
Expand Down
12 changes: 6 additions & 6 deletions shaders/cAntiAliasing.fx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
Copyright (C) LucasArts 2010-2011
*/

uniform int _DisplayMode <
ui_label = "Display Mode";
ui_type = "radio";
ui_items = "Output\0Mask\0";
uniform int _RenderMode <
ui_label = "Render Mode";
ui_type = "combo";
ui_items = "Render Image\0Render Mask\0";
> = 0;

#include "shared/cShade.fxh"
Expand Down Expand Up @@ -178,12 +178,12 @@ float4 PS_AntiAliasing(CShade_VS2PS_Quad Input) : SV_TARGET0
float4 R = (4.0 * (R0 + R1 + R2 + R3) + Center + Top01 + Bottom01 + Left01 + Right01) / 25.0;
Color = lerp(Color, Center, saturate(R.a * 3.0 - 1.5));

if (_DisplayMode == 1)
if (_RenderMode == 1)
{
return Center.a;
}

return float4(Color.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(Color.rgb, _CShadeAlphaFactor));
}

technique CShade_AntiAliasing
Expand Down
2 changes: 1 addition & 1 deletion shaders/cAutoExposure.fx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ float3 PS_Exposure(CShade_VS2PS_Quad Input) : SV_TARGET0
Output = lerp(Output, LumaIcon.rgb, LumaIcon.a);
}

return float4(Output.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(Output.rgb, _CShadeAlphaFactor));
}

technique CShade_AutoExposure
Expand Down
2 changes: 1 addition & 1 deletion shaders/cBilateral.fx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ float4 PS_Bilateral(CShade_VS2PS_Quad Input) : SV_TARGET0
}
}

return float4(OutputColor / TotalWeight, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(OutputColor / TotalWeight, _CShadeAlphaFactor));
}

technique CShade_Bilateral
Expand Down
30 changes: 24 additions & 6 deletions shaders/cBloom.fx
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,44 @@
uniform float _Frametime < source = "frametime"; >;

uniform float _Threshold <
ui_category = "Bloom | Input";
ui_category = "Bloom | General";
ui_label = "Threshold";
ui_type = "slider";
ui_min = 0.0;
ui_max = 1.0;
> = 0.8;

uniform float _Smooth <
ui_category = "Bloom | Input";
ui_category = "Bloom | General";
ui_label = "Smoothing";
ui_type = "slider";
ui_min = 0.0;
ui_max = 1.0;
> = 0.5;

uniform float3 _ColorShift <
ui_category = "Bloom | Input";
ui_category = "Bloom | General";
ui_label = "Color Shift (RGB)";
ui_type = "color";
ui_min = 0.0;
ui_max = 1.0;
> = 1.0;

uniform float _Intensity <
ui_category = "Bloom | Input";
ui_category = "Bloom | General";
ui_label = "Intensity";
ui_type = "slider";
ui_step = 0.001;
ui_min = 0.0;
ui_max = 1.0;
> = 0.5;

uniform int _RenderMode <
ui_label = "Render Mode";
ui_type = "combo";
ui_items = "Base + Bloom\0Bloom\0";
> = 0;

uniform float _Level8Weight <
ui_category = "Bloom | Level Weights";
ui_label = "Level 8";
Expand Down Expand Up @@ -229,9 +235,21 @@ float4 PS_Composite(CShade_VS2PS_Quad Input) : SV_TARGET0
{
float3 BaseColor = tex2D(CShade_SampleColorTex, Input.Tex0).rgb;
float3 BloomColor = tex2D(SampleTempTex1, Input.Tex0).rgb;
float3 Color = CTonemap_ApplyOutputTonemap(BaseColor + (BloomColor * _Intensity));

return float4(Color, _CShadeAlphaFactor);
// Bloom composition
float3 Color = 0.0;
switch (_RenderMode)
{
case 0:
Color = BaseColor + (BloomColor * _Intensity);
break;
case 1:
Color = BloomColor * _Intensity;
break;
}
Color = CTonemap_ApplyOutputTonemap(Color);

return CBlend_OutputChannels(float4(Color, _CShadeAlphaFactor));
}

#define CREATE_PASS(VERTEX_SHADER, PIXEL_SHADER, RENDER_TARGET, IS_ADDITIVE) \
Expand Down
2 changes: 1 addition & 1 deletion shaders/cCheckerBoard.fx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ float4 PS_Checkerboard(CShade_VS2PS_Quad Input) : SV_TARGET0
Checkerboard = _InvertCheckerboard ? 1.0 - Checkerboard : Checkerboard;
Checkerboard = Checkerboard == 1.0 ? _Color1 : _Color2;

return float4(Checkerboard, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(Checkerboard, _CShadeAlphaFactor));
}

technique CShade_CheckerBoard
Expand Down
2 changes: 1 addition & 1 deletion shaders/cChromaticity.fx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ float4 PS_Chromaticity(CShade_VS2PS_Quad Input) : SV_TARGET0
break;
}

return float4(Chromaticity.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(Chromaticity.rgb, _CShadeAlphaFactor));
}

technique CShade_Chromaticity
Expand Down
4 changes: 2 additions & 2 deletions shaders/cCircles.fx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ float4 PS_Blit(CShade_VS2PS_Quad Input) : SV_TARGET0
OutputColor = lerp(_BackColor, OutputColor, MainTiles.Value.y > _Crop.z * 2.0);
OutputColor = lerp(_BackColor, OutputColor, MainTiles.Value.y < (_CircleAmount - _Crop.w * 2.0));

return float4(OutputColor.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(OutputColor.rgb, _CShadeAlphaFactor));
}
#else
float4 PS_Circles(CShade_VS2PS_Quad Input) : SV_TARGET0
Expand Down Expand Up @@ -347,7 +347,7 @@ float4 PS_Blit(CShade_VS2PS_Quad Input) : SV_TARGET0
CropChannel(OutputColor.g, 1, GreenChannel_Tiles, _GreenChannelCrop);
CropChannel(OutputColor.b, 2, BlueChannel_Tiles, _BlueChannelCrop);

return float4(OutputColor.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(OutputColor.rgb, _CShadeAlphaFactor));
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion shaders/cColorBand.fx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ float4 PS_Color(CShade_VS2PS_Quad Input) : SV_TARGET0

ColorMap.rgb = floor(ColorMap.rgb * _Range) / (_Range);

return float4(ColorMap.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(ColorMap.rgb, _CShadeAlphaFactor));
}

technique CShade_ColorBand
Expand Down
4 changes: 2 additions & 2 deletions shaders/cContrastNormalization.fx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ float4 PS_ContrastNormalization(CShade_VS2PS_Quad Input) : SV_TARGET0
{
case 0:
float4 LCN = GetLocalContrastNormalization(CShade_SampleColorTex, Input.Tex0);
return float4(((float3)CColor_GetLuma(LCN.rgb, 0) * 0.5) + 0.5, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(((float3)CColor_GetLuma(LCN.rgb, 0) * 0.5) + 0.5, _CShadeAlphaFactor));
case 1:
float4 CT = GetCensusTransform(CShade_SampleColorTex, Input.Tex0);
return float4((float3)CColor_GetLuma(CT.rgb, 0), _CShadeAlphaFactor);
return CBlend_OutputChannels(float4((float3)CColor_GetLuma(CT.rgb, 0), _CShadeAlphaFactor));
default:
return 0.5;
}
Expand Down
2 changes: 1 addition & 1 deletion shaders/cEnsor.fx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace cEnsor
OutputColor = lerp(Color, Pixel, Mask);
}

return float4(OutputColor.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(OutputColor.rgb, _CShadeAlphaFactor));
}

technique CShade_Censor
Expand Down
2 changes: 1 addition & 1 deletion shaders/cFrameBlend.fx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ float4 PS_Blend(CShade_VS2PS_Quad Input) : SV_TARGET0
float4 PS_Display(CShade_VS2PS_Quad Input) : SV_TARGET0
{
// Display the buffer
return float4(tex2D(SampleBlendTex, Input.Tex0).rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(tex2D(SampleBlendTex, Input.Tex0).rgb, _CShadeAlphaFactor));
}

technique CShade_FrameBlend
Expand Down
4 changes: 2 additions & 2 deletions shaders/cGaussianBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ float4 GetGaussianBlur(float2 Tex, bool IsHorizontal)

float4 PS_HGaussianBlur(CShade_VS2PS_Quad Input) : SV_TARGET0
{
return float4(GetGaussianBlur(Input.Tex0, true).rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(GetGaussianBlur(Input.Tex0, true).rgb, _CShadeAlphaFactor));
}

float4 PS_VGaussianBlur(CShade_VS2PS_Quad Input) : SV_TARGET0
{
return float4(GetGaussianBlur(Input.Tex0, false).rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(GetGaussianBlur(Input.Tex0, false).rgb, _CShadeAlphaFactor));
}

technique CShade_HorizontalBlur
Expand Down
2 changes: 1 addition & 1 deletion shaders/cGrayscale.fx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ float4 PS_Luminance(CShade_VS2PS_Quad Input) : SV_TARGET0
{
float4 Color = tex2D(CShade_SampleColorTex, Input.Tex0);
float3 Luma = CColor_GetLuma(Color.rgb, _Select);
return float4(Luma, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(Luma, _CShadeAlphaFactor));
}

technique CShade_Grayscale
Expand Down
12 changes: 6 additions & 6 deletions shaders/cImageSharpen.fx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ uniform float _Contrast <
ui_max = 1.0;
> = 0.0;

uniform int _DisplayMode <
ui_label = "Display Mode";
ui_type = "radio";
ui_items = "Output\0Mask\0";
uniform int _RenderMode <
ui_label = "Render Mode";
ui_type = "combo";
ui_items = "Render Image\0Render Mask\0";
> = 0;

#include "shared/cShade.fxh"
Expand All @@ -69,12 +69,12 @@ float4 PS_CasFilterNoScaling(CShade_VS2PS_Quad Input): SV_TARGET0
_Contrast
);

if (_DisplayMode == 1)
if (_RenderMode == 1)
{
OutputColor = OutputMask;
}

return float4(OutputColor.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(OutputColor.rgb, _CShadeAlphaFactor));
}

technique CShade_ImageSharpen
Expand Down
2 changes: 1 addition & 1 deletion shaders/cLens.fx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ float4 PS_Lens(CShade_VS2PS_Quad Input): SV_TARGET0
_Vignette,
Seed
);
return float4(OutputColor.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(OutputColor.rgb, _CShadeAlphaFactor));
}

technique CShade_Lens
Expand Down
2 changes: 1 addition & 1 deletion shaders/cLetterBox.fx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ float4 PS_Letterbox(CShade_VS2PS_Quad Input) : SV_TARGET0
Input.Tex0 = (Input.Tex0 * 2.0) - 1.0;
Input.Tex0 += _Offset;
float2 Shaper = step(abs(Input.Tex0), _Scale);
return float4(Shaper.xxx * Shaper.yyy, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(Shaper.xxx * Shaper.yyy, _CShadeAlphaFactor));
}

#undef CBLEND_BLENDENABLE
Expand Down
2 changes: 1 addition & 1 deletion shaders/cMotionBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ namespace cMotionBlur
OutputColor += tex2D(CShade_SampleColorTex, RandomTex);
}

return float4(OutputColor.rgb / Samples, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(OutputColor.rgb / Samples, _CShadeAlphaFactor));
}

#define CREATE_PASS(VERTEX_SHADER, PIXEL_SHADER, RENDER_TARGET) \
Expand Down
2 changes: 1 addition & 1 deletion shaders/cNoiseBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ float4 PS_NoiseBlur(CShade_VS2PS_Quad Input) : SV_TARGET0
}
}

return float4(OutputColor.rgb / Weight, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(OutputColor.rgb / Weight, _CShadeAlphaFactor));
}

technique CShade_NoiseBlur
Expand Down
2 changes: 1 addition & 1 deletion shaders/cPixelate.fx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ float4 PS_Color(CShade_VS2PS_Quad Input) : SV_TARGET0
float2 Tex = floor(Input.Tex0 * _Pixels) / _Pixels;
float4 OutputColor = tex2D(CShade_SampleColorTex, Tex);

return float4(OutputColor.rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(OutputColor.rgb, _CShadeAlphaFactor));
}

technique CShade_Pixelate
Expand Down
12 changes: 4 additions & 8 deletions shaders/cSolidColor.fx
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@

#include "shared/cShade.fxh"
#include "shared/cBlend.fxh"

/*
[Shader Options]
*/

uniform float3 _Color <
ui_label = "Color";
ui_type = "color";
ui_min = 0.0;
> = 1.0;

#include "shared/cShade.fxh"
#include "shared/cBlend.fxh"

/*
[Pixel Shaders]
*/

float4 PS_Color(CShade_VS2PS_Quad Input) : SV_TARGET0
{
return float4(_Color, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(_Color, _CShadeAlphaFactor));
}

// Use BlendOp to multiple the backbuffer with this quad's color
Expand Down
2 changes: 1 addition & 1 deletion shaders/cThreshold.fx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ float4 PS_Threshold(CShade_VS2PS_Quad Input) : SV_TARGET0
// Combine and apply the brightness response curve
Color = Color * max(ResponseCurve, Brightness - _Threshold) / max(Brightness, 1e-10);
Brightness = CMath_Med3(Color.r, Color.g, Color.b).a;
return float4(saturate(lerp(Brightness, Color.rgb, _Saturation) * _Intensity), _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(saturate(lerp(Brightness, Color.rgb, _Saturation) * _Intensity), _CShadeAlphaFactor));
}

technique CShade_Threshold
Expand Down
2 changes: 1 addition & 1 deletion shaders/cTransform.fx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ CShade_VS2PS_Quad VS_Matrix(CShade_APP2VS Input)

float4 PS_Matrix(CShade_VS2PS_Quad Input) : SV_TARGET0
{
return float4(tex2D(CShade_SampleColorTex, Input.Tex0).rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(tex2D(CShade_SampleColorTex, Input.Tex0).rgb, _CShadeAlphaFactor));
}

technique CShade_Transform
Expand Down
2 changes: 1 addition & 1 deletion shaders/kDatamosh.fx
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ namespace kDatamosh
CW = lerp(CW, 1.0, Rand.w < lerp(0.2, 1.0, Quality) * (Disp > (1.0 - 1e-3)));

// If the conditions above are not met, choose work.
return float4(lerp(Work.rgb, Source.rgb, CW), _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(lerp(Work.rgb, Source.rgb, CW), _CShadeAlphaFactor));
}

float4 PS_CopyColorTex(CShade_VS2PS_Quad Input) : SV_TARGET0
Expand Down
2 changes: 1 addition & 1 deletion shaders/kMirror.fx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ float4 PS_Mirror(CShade_VS2PS_Quad Input) : SV_TARGET0

// Reflection at the border of the screen.
Input.Tex0 = max(min(Input.Tex0, 2.0 - Input.Tex0), -Input.Tex0);
return float4(tex2D(CShade_SampleColorTex, Input.Tex0).rgb, _CShadeAlphaFactor);
return CBlend_OutputChannels(float4(tex2D(CShade_SampleColorTex, Input.Tex0).rgb, _CShadeAlphaFactor));
}

technique CShade_KinoMirror
Expand Down
Loading

0 comments on commit 198b5a4

Please sign in to comment.