diff --git a/shaders/cBlend.fx b/shaders/cBlend.fx index 2827c37..cff8b7f 100644 --- a/shaders/cBlend.fx +++ b/shaders/cBlend.fx @@ -4,10 +4,18 @@ [Shader Options] */ -uniform int _Blend < - ui_label = "Blend Mode"; +#include "shared/cColor.fxh" + +uniform int _ColorBlend < + ui_label = "Color Blend Mode"; + ui_type = "combo"; + ui_items = "Normal\0Multiply\0Screen\0Overlay\0Darken\0Lighten\0Color Dodge\0Color Burn\0Hard Light\0Soft Light\0Difference\0Exclusion\0"; +> = 0; + +uniform int _AlphaBlend < + ui_label = "Alpha Blend Mode"; ui_type = "combo"; - ui_items = "Add\0Subtract\0Multiply\0Min\0Max\0Screen\0"; + ui_items = "Normal\0Multiply\0Screen\0Overlay\0Darken\0Lighten\0Color Dodge\0Color Burn\0Hard Light\0Soft Light\0Difference\0Exclusion\0"; > = 0; uniform float3 _SrcFactor < @@ -44,37 +52,19 @@ float4 PS_Copy(CShade_VS2PS_Quad Input) : SV_TARGET0 float4 PS_Blend(CShade_VS2PS_Quad Input) : SV_TARGET0 { - float4 Src = tex2D(SampleSrcTex, Input.Tex0) * float4(_SrcFactor, 1.0); - float4 Dest = tex2D(SampleDestTex, Input.Tex0) * float4(_DestFactor, 1.0); + float4 Src = tex2D(SampleSrcTex, Input.Tex0); + float4 Dest = tex2D(SampleDestTex, Input.Tex0); - float4 OutputColor = 0.0; + Src.rgb *= _SrcFactor; + Dest.rgb *= _DestFactor; - switch(_Blend) - { - case 0: // Add - OutputColor = Src + Dest; - break; - case 1: // Subtract - OutputColor = Src - Dest; - break; - case 2: // Multiply - OutputColor = Src * Dest; - break; - case 3: // Min - OutputColor = min(Src, Dest); - break; - case 4: // Max - OutputColor = max(Src, Dest); - break; - case 5: // Screen - OutputColor = (Src + Dest) - (Src * Dest); - break; - default: - OutputColor = Dest; - break; - } + float3 SrcAlpha = Src.a; + float3 DestAlpha = Dest.a; + + float3 ColorBlend = CColor_Blend(Dest.rgb, Src.rgb, _ColorBlend); + float AlphaBlend = CColor_Blend(DestAlpha, SrcAlpha, _AlphaBlend).r; - return OutputColor; + return float4(ColorBlend, AlphaBlend); } technique CShade_CopyBuffer < ui_tooltip = "Create CBlend's copy texture"; > diff --git a/shaders/cRaySchism.fx b/shaders/cRaySchism.fx index d1dfcc1..0e99df4 100644 --- a/shaders/cRaySchism.fx +++ b/shaders/cRaySchism.fx @@ -169,8 +169,8 @@ uniform float _GradeBalance < ui_category = "Color Grading | Split Toning"; ui_label = "Balance"; ui_type = "slider"; - ui_min = -100.0; - ui_max = 100.0; + ui_min = -1.0; + ui_max = 1.0; > = 0.0; uniform float3 _GradeMixRed < diff --git a/shaders/shared/cColor.fxh b/shaders/shared/cColor.fxh index 0cc7895..72dd5b3 100644 --- a/shaders/shared/cColor.fxh +++ b/shaders/shared/cColor.fxh @@ -107,6 +107,8 @@ return CColor_BlendDifference(B, S); case 11: // Exclusion return CColor_BlendExclusion(B, S); + default: + return CColor_BlendNormal(B, S); } } @@ -349,22 +351,22 @@ static const float3x3 CColor_OKLABfromRGB_M1 = float3x3 ( - float3(0.4122214708, +0.5363325363, +0.0514459929), - float3(0.2119034982, +0.6806995451, +0.1073969566), - float3(0.0883024619, +0.2817188376, +0.6299787005) + float3(+0.4122214708, +0.5363325363, +0.0514459929), + float3(+0.2119034982, +0.6806995451, +0.1073969566), + float3(+0.0883024619, +0.2817188376, +0.6299787005) ); static const float3x3 CColor_OKLABfromRGB_M2 = float3x3 ( - float3(0.2104542553, +0.7936177850f, -0.0040720468), - float3(1.9779984951, -2.4285922050f, +0.4505937099), - float3(0.0259040371, +0.7827717662f, -0.8086757660) + float3(+0.2104542553, +0.7936177850f, -0.0040720468), + float3(+1.9779984951, -2.4285922050f, +0.4505937099), + float3(+0.0259040371, +0.7827717662f, -0.8086757660) ); float3 CColor_GetOKLABfromRGB(float3 Color) { float3 LMS = mul(CColor_OKLABfromRGB_M1, Color); - LMS = pow(LMS, 1.0 / 3.0); + LMS = pow(abs(LMS), 1.0 / 3.0); LMS = mul(CColor_OKLABfromRGB_M2, LMS); return LMS; }; @@ -531,8 +533,8 @@ float Temperature, // [-1.0, 1.0); default = 0.0 float Tint, // [-1.0, 1.0); default = 0.0 float3 Shadows, // [0.0, 1.0); default = float3(0.5, 0.5, 0.5) - float3 HighLights, // [0.0, 1.0); default = float3(0.5, 0.5, 0.5) - float Balance, // [-100.0, 100.0); default = 0.0 + float3 Highlights, // [0.0, 1.0); default = float3(0.5, 0.5, 0.5) + float Balance, // [-1.0, 1.0); default = 0.0 float3 MixRed, // [0.0, 1.0); default = float3(1.0, 0.0, 0.0) float3 MixGreen, // [0.0, 1.0); default = float3(0.0, 1.0, 0.0) float3 MixBlue, // [0.0, 1.0); default = float3(0.0, 0.0, 1.0) @@ -593,7 +595,7 @@ Color = pow(abs(Color), 1.0 / 2.2); float T = saturate(CColor_GetLuma(Color, 0) + Balance); float3 SplitShadows = lerp(0.5, Shadows, 1.0 - T); - float3 SplitHighlights = lerp(0.5, HighLights, T); + float3 SplitHighlights = lerp(0.5, Highlights, T); Color = CColor_BlendSoftLight(Color, SplitShadows); Color = CColor_BlendSoftLight(Color, SplitHighlights); Color = pow(abs(Color), 2.2);