|
7 | 7 | #include "../Effects/BlendEffect.hpp" |
8 | 8 | #include "../Effects/ExposureEffect.hpp" |
9 | 9 | #include "../Effects/CompositeEffect.hpp" |
| 10 | +#include "../Effects/SaturationEffect.hpp" |
10 | 11 |
|
11 | 12 | namespace MDWMBlurGlassExt |
12 | 13 | { |
@@ -44,67 +45,106 @@ namespace MDWMBlurGlassExt |
44 | 45 | bool hostBackdrop |
45 | 46 | ) try |
46 | 47 | { |
47 | | - // New Aero backdrop recipe by @ALTaleX531 (https://github.com/ALTaleX531/MDWMBlurGlassExt), @aubymori (normal layer fixes) |
48 | | - // @kfh83 for porting to DWMBlurGlass and minor modifications |
| 48 | + // New Aero backdrop recive v2, thx 2 @aubymori and @wackyideas for some help |
49 | 49 |
|
50 | | - auto colorEffect{ winrt::make_self<ColorSourceEffect>() }; |
51 | | - colorEffect->SetName(L"MainColor"); |
52 | | - colorEffect->SetColor(mainColor); |
| 50 | + // define the colors used |
53 | 51 |
|
54 | | - auto colorOpacityEffect{ winrt::make_self<OpacityEffect>() }; |
55 | | - colorOpacityEffect->SetName(L"MainColorOpacity"); |
56 | | - colorOpacityEffect->SetInput(*colorEffect); |
57 | | - colorOpacityEffect->SetOpacity(colorBalance); |
| 52 | + // before you ask why i have 3 of the color black, ask Direct2D first why i can't just reuse this color |
58 | 53 |
|
59 | | - auto glowColorEffect{ winrt::make_self<ColorSourceEffect>() }; |
60 | | - glowColorEffect->SetName(L"GlowColor"); |
61 | | - glowColorEffect->SetColor(glowColor); |
| 54 | + winrt::Windows::UI::Color black{ 255,0,0,0 }; |
| 55 | + winrt::Windows::UI::Color black2{ 255,0,0,0 }; |
| 56 | + winrt::Windows::UI::Color black3{ 255,0,0,0 }; |
62 | 57 |
|
63 | | - auto glowOpacityEffect{ winrt::make_self<OpacityEffect>() }; |
64 | | - glowOpacityEffect->SetName(L"GlowColorOpacity"); |
65 | | - glowOpacityEffect->SetInput(*glowColorEffect); |
66 | | - glowOpacityEffect->SetOpacity(glowBalance); |
| 58 | + auto ColorizationColor{ winrt::make_self<ColorSourceEffect>() }; |
| 59 | + ColorizationColor->SetName(L"MainColor"); |
| 60 | + ColorizationColor->SetColor(mainColor); |
67 | 61 |
|
68 | | - auto blurredBackdropBalanceEffect{ winrt::make_self<ExposureEffect>() }; |
69 | | - blurredBackdropBalanceEffect->SetName(L"BlurBalance"); |
70 | | - blurredBackdropBalanceEffect->SetExposureAmount(blurBalance); |
| 62 | + auto ColorizationAfterglow{ winrt::make_self<ColorSourceEffect>() }; |
| 63 | + ColorizationAfterglow->SetName(L"GlowColor"); |
| 64 | + ColorizationAfterglow->SetColor(glowColor); |
71 | 65 |
|
72 | | - if (hostBackdrop) |
73 | | - { |
74 | | - blurredBackdropBalanceEffect->SetInput(winrt::Windows::UI::Composition::CompositionEffectSourceParameter{ L"Backdrop" }); |
75 | | - } |
76 | | - else |
77 | | - { |
78 | | - auto gaussianBlurEffect{ winrt::make_self<GaussianBlurEffect>() }; |
79 | | - gaussianBlurEffect->SetName(L"Blur"); |
80 | | - gaussianBlurEffect->SetBorderMode(D2D1_BORDER_MODE_HARD); |
81 | | - gaussianBlurEffect->SetBlurAmount(blurAmount); |
82 | | - gaussianBlurEffect->SetInput(winrt::Windows::UI::Composition::CompositionEffectSourceParameter{ L"Backdrop" }); |
83 | | - blurredBackdropBalanceEffect->SetInput(*gaussianBlurEffect); |
84 | | - } |
| 66 | + // again this is disgusting and i hate that i have to use it, but Direct2D will NOT let me use brushes & colors |
| 67 | + |
| 68 | + auto BalanceBackdrop{ winrt::make_self<ColorSourceEffect>() }; // used to blend against the layers thus acting as the balance |
| 69 | + BalanceBackdrop->SetColor(black); |
| 70 | + |
| 71 | + auto BalanceBackdrop2{ winrt::make_self<ColorSourceEffect>() }; // used to blend against the layers thus acting as the balance |
| 72 | + BalanceBackdrop2->SetColor(black2); |
| 73 | + |
| 74 | + auto BalanceBackdrop3{ winrt::make_self<ColorSourceEffect>() }; // used to blend against the layers thus acting as the balance |
| 75 | + BalanceBackdrop3->SetColor(black3); |
| 76 | + |
| 77 | + // gaussian blur backdrop |
| 78 | + |
| 79 | + // apparently i CANNOT REUSE brushes... so here goes 2 gaussian blur brushes !!! |
| 80 | + |
| 81 | + auto AfterglowBlur{ winrt::make_self<GaussianBlurEffect>() }; |
| 82 | + AfterglowBlur->SetBorderMode(D2D1_BORDER_MODE_HARD); |
| 83 | + AfterglowBlur->SetBlurAmount(blurAmount); |
| 84 | + AfterglowBlur->SetInput(winrt::Windows::UI::Composition::CompositionEffectSourceParameter{ L"Backdrop" }); |
85 | 85 |
|
86 | | - auto glowBlendEffect{ winrt::make_self<BlendEffect>() }; |
87 | | - glowBlendEffect->SetBlendMode(D2D1_BLEND_MODE_MULTIPLY); |
88 | | - glowBlendEffect->SetBackground(*blurredBackdropBalanceEffect); |
89 | | - glowBlendEffect->SetForeground(*glowOpacityEffect); |
| 86 | + auto RegularBlur{ winrt::make_self<GaussianBlurEffect>() }; |
| 87 | + RegularBlur->SetBorderMode(D2D1_BORDER_MODE_HARD); |
| 88 | + RegularBlur->SetBlurAmount(blurAmount); |
| 89 | + RegularBlur->SetInput(winrt::Windows::UI::Composition::CompositionEffectSourceParameter{ L"Backdrop" }); |
90 | 90 |
|
91 | | - auto glowBalanceEffect{ winrt::make_self<ExposureEffect>() }; |
92 | | - glowBalanceEffect->SetName(L"GlowBalance"); |
93 | | - glowBalanceEffect->SetExposureAmount(glowBalance / 10.f); |
94 | | - glowBalanceEffect->SetInput(*glowBlendEffect); |
| 91 | + // ColorizationColor -- render semi-transparent color over black bg |
95 | 92 |
|
96 | | - auto compositeEffect{ winrt::make_self<CompositeStepEffect>() }; |
97 | | - compositeEffect->SetCompositeMode(D2D1_COMPOSITE_MODE_SOURCE_OVER); |
98 | | - compositeEffect->SetName(L"Composite"); |
99 | | - compositeEffect->SetDestination(*glowBalanceEffect); |
100 | | - compositeEffect->SetSource(*colorOpacityEffect); |
| 93 | + auto ColorizationColorBalance{ winrt::make_self<OpacityEffect>() }; |
| 94 | + ColorizationColorBalance->SetInput(*ColorizationColor); |
| 95 | + ColorizationColorBalance->SetOpacity(colorBalance); |
101 | 96 |
|
102 | | - auto colorBalanceEffect{ winrt::make_self<ExposureEffect>() }; |
103 | | - colorBalanceEffect->SetName(L"ColorBalance"); |
104 | | - colorBalanceEffect->SetExposureAmount(colorBalance / 10.f); |
105 | | - colorBalanceEffect->SetInput(*compositeEffect); |
| 97 | + auto ColorizationColorRender{ winrt::make_self<CompositeStepEffect>() }; |
| 98 | + ColorizationColorRender->SetCompositeMode(D2D1_COMPOSITE_MODE_SOURCE_OVER); |
| 99 | + ColorizationColorRender->SetDestination(*BalanceBackdrop); |
| 100 | + ColorizationColorRender->SetSource(*ColorizationColorBalance); |
106 | 101 |
|
107 | | - auto effectBrush{ compositor.CreateEffectFactory(*colorBalanceEffect).CreateBrush() }; |
| 102 | + // ColorizationAfterglow -- multiply over b&w bg, over black bg |
| 103 | + |
| 104 | + auto CAGSetSaturation{ winrt::make_self<SaturationEffect>() }; |
| 105 | + CAGSetSaturation->SetInput(*AfterglowBlur); |
| 106 | + CAGSetSaturation->SetSaturation(0); |
| 107 | + |
| 108 | + auto ColorizationAfterglowBlend{ winrt::make_self<BlendEffect>() }; |
| 109 | + ColorizationAfterglowBlend->SetBlendMode(D2D1_BLEND_MODE_MULTIPLY); |
| 110 | + ColorizationAfterglowBlend->SetBackground(*CAGSetSaturation); |
| 111 | + ColorizationAfterglowBlend->SetForeground(*ColorizationAfterglow); |
| 112 | + |
| 113 | + auto ColorizationAfterglowBalance{ winrt::make_self<OpacityEffect>() }; |
| 114 | + ColorizationAfterglowBalance->SetInput(*ColorizationAfterglowBlend); |
| 115 | + ColorizationAfterglowBalance->SetOpacity(glowBalance); |
| 116 | + |
| 117 | + auto ColorizationAfterglowRender{ winrt::make_self<CompositeStepEffect>() }; |
| 118 | + ColorizationAfterglowRender->SetCompositeMode(D2D1_COMPOSITE_MODE_SOURCE_OVER); |
| 119 | + ColorizationAfterglowRender->SetDestination(*BalanceBackdrop2); |
| 120 | + ColorizationAfterglowRender->SetSource(*ColorizationAfterglowBalance); |
| 121 | + |
| 122 | + // ColorizationBlurBalance -- gaussian blur over black bg |
| 123 | + |
| 124 | + auto ColorizationBlurBalance{ winrt::make_self<OpacityEffect>() }; |
| 125 | + ColorizationBlurBalance->SetName(L"gaussianBlurEffect"); |
| 126 | + ColorizationBlurBalance->SetInput(*RegularBlur); |
| 127 | + ColorizationBlurBalance->SetOpacity(blurBalance); |
| 128 | + |
| 129 | + auto ColorizationBlurBalanceRender{ winrt::make_self<CompositeStepEffect>() }; |
| 130 | + ColorizationBlurBalanceRender->SetCompositeMode(D2D1_COMPOSITE_MODE_SOURCE_OVER); |
| 131 | + ColorizationBlurBalanceRender->SetName(L"ColorizationBlurBalanceRender"); |
| 132 | + ColorizationBlurBalanceRender->SetDestination(*BalanceBackdrop3); |
| 133 | + ColorizationBlurBalanceRender->SetSource(*ColorizationBlurBalance); |
| 134 | + |
| 135 | + // blend everything together with ADDITIVE BLENDING... it's not color dodge folks!!! |
| 136 | + |
| 137 | + auto ColorOverBlur{ winrt::make_self<CompositeStepEffect>() }; |
| 138 | + ColorOverBlur->SetCompositeMode(D2D1_COMPOSITE_MODE_PLUS); |
| 139 | + ColorOverBlur->SetDestination(*ColorizationAfterglowRender); |
| 140 | + ColorOverBlur->SetSource(*ColorizationColorRender); |
| 141 | + |
| 142 | + auto BlendOverBlur{ winrt::make_self<CompositeStepEffect>() }; |
| 143 | + BlendOverBlur->SetCompositeMode(D2D1_COMPOSITE_MODE_PLUS); |
| 144 | + BlendOverBlur->SetDestination(*ColorizationBlurBalanceRender); |
| 145 | + BlendOverBlur->SetSource(*ColorOverBlur); |
| 146 | + |
| 147 | + auto effectBrush{ compositor.CreateEffectFactory(*BlendOverBlur).CreateBrush() }; |
108 | 148 | if (hostBackdrop) |
109 | 149 | { |
110 | 150 | effectBrush.SetSourceParameter(L"Backdrop", compositor.CreateHostBackdropBrush()); |
@@ -132,18 +172,20 @@ namespace MDWMBlurGlassExt |
132 | 172 | lightMode_Active_GlowColor = lightMode_Active_Color; |
133 | 173 | lightMode_Inactive_GlowColor = lightMode_Inactive_Color; |
134 | 174 |
|
135 | | - lightMode_Active_ColorBalance = g_configData.activeColorBalance; |
136 | | - lightMode_Inactive_ColorBalance = g_configData.inactiveColorBalance; |
137 | | - darkMode_Active_ColorBalance = g_configData.activeColorBalance; |
138 | | - darkMode_Inactive_ColorBalance = g_configData.inactiveColorBalance; |
| 175 | + // please altalex keep this as is or atleast try to keep this behavior |
| 176 | + |
| 177 | + lightMode_Active_ColorBalance = g_configData.ColorizationColorBalance / 100.0f; |
| 178 | + lightMode_Inactive_ColorBalance = lightMode_Active_ColorBalance * 0.4f; |
| 179 | + darkMode_Active_ColorBalance = g_configData.ColorizationColorBalance / 100.0f; |
| 180 | + darkMode_Inactive_ColorBalance = darkMode_Active_ColorBalance * 0.4f; |
139 | 181 |
|
140 | | - lightMode_Active_GlowBalance = GetFloatAlpha(g_configData.activeBlendColor); |
141 | | - lightMode_Inactive_GlowBalance = GetFloatAlpha(g_configData.inactiveBlendColor); |
142 | | - darkMode_Active_GlowBalance = GetFloatAlpha(g_configData.activeBlendColorDark); |
143 | | - darkMode_Inactive_GlowBalance = GetFloatAlpha(g_configData.inactiveBlendColorDark); |
| 182 | + lightMode_Active_GlowBalance = g_configData.ColorizationAfterglowBalance / 100.0f; |
| 183 | + lightMode_Inactive_GlowBalance = g_configData.ColorizationAfterglowBalance / 100.0f; |
| 184 | + darkMode_Active_GlowBalance = g_configData.ColorizationAfterglowBalance / 100.0f; |
| 185 | + darkMode_Inactive_GlowBalance = g_configData.ColorizationAfterglowBalance / 100.0f; |
144 | 186 |
|
145 | | - Active_BlurBalance = g_configData.activeBlurBalance; |
146 | | - Inactive_BlurBalance = g_configData.inactiveBlurBalance; |
| 187 | + Active_BlurBalance = g_configData.ColorizationBlurBalance / 100.0f; |
| 188 | + Inactive_BlurBalance = (Active_BlurBalance * 0.4) + 0.60; |
147 | 189 |
|
148 | 190 | blurAmount = g_configData.customBlurAmount; |
149 | 191 | } |
|
0 commit comments