mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 12:51:42 +00:00
Implement bevel.
This commit is contained in:
parent
82aee0951a
commit
06242223a3
5 changed files with 46 additions and 4 deletions
|
|
@ -7,6 +7,8 @@
|
||||||
#define IMGUI_SHADER_MODIFIER_TEXT_SKEW 4
|
#define IMGUI_SHADER_MODIFIER_TEXT_SKEW 4
|
||||||
#define IMGUI_SHADER_MODIFIER_MARQUEE_FADE 5
|
#define IMGUI_SHADER_MODIFIER_MARQUEE_FADE 5
|
||||||
#define IMGUI_SHADER_MODIFIER_GRAYSCALE 6
|
#define IMGUI_SHADER_MODIFIER_GRAYSCALE 6
|
||||||
|
#define IMGUI_SHADER_MODIFIER_TITLE_BEVEL 7
|
||||||
|
#define IMGUI_SHADER_MODIFIER_CATEGORY_BEVEL 8
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,31 @@ float4 main(in Interpolators interpolators) : SV_Target
|
||||||
float sd = median(textureColor.r, textureColor.g, textureColor.b) - 0.5;
|
float sd = median(textureColor.r, textureColor.g, textureColor.b) - 0.5;
|
||||||
float screenPxDistance = screenPxRange * (sd + g_PushConstants.Outline / (pxRange * 2.0));
|
float screenPxDistance = screenPxRange * (sd + g_PushConstants.Outline / (pxRange * 2.0));
|
||||||
|
|
||||||
|
if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_TITLE_BEVEL)
|
||||||
|
{
|
||||||
|
float2 normal = normalize(float3(ddx(sd), ddy(sd), 0.01)).xy;
|
||||||
|
float3 rimColor = float3(1, 0.8, 0.29);
|
||||||
|
float3 shadowColor = float3(0.84, 0.57, 0);
|
||||||
|
|
||||||
|
float cosTheta = dot(normal, normalize(float2(1, 1)));
|
||||||
|
float3 gradient = lerp(color.rgb, cosTheta >= 0.0 ? rimColor : shadowColor, abs(cosTheta));
|
||||||
|
color.rgb = lerp(gradient, color.rgb, pow(saturate(sd + 0.8), 32.0));
|
||||||
|
}
|
||||||
|
else if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_CATEGORY_BEVEL)
|
||||||
|
{
|
||||||
|
float2 normal = normalize(float3(ddx(sd), ddy(sd), 0.25)).xy;
|
||||||
|
float cosTheta = dot(normal, normalize(float2(1, 1)));
|
||||||
|
float gradient = 1.0 + cosTheta * 0.5;
|
||||||
|
color.rgb = saturate(color.rgb * gradient);
|
||||||
|
}
|
||||||
|
else if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_TEXT_SKEW)
|
||||||
|
{
|
||||||
|
float2 normal = normalize(float3(ddx(sd), ddy(sd), 0.5)).xy;
|
||||||
|
float cosTheta = dot(normal, normalize(float2(1, 1)));
|
||||||
|
float gradient = saturate(1.0 + cosTheta);
|
||||||
|
color.rgb = lerp(color.rgb * gradient, color.rgb, pow(saturate(sd + 0.77), 32.0));
|
||||||
|
}
|
||||||
|
|
||||||
color.a *= saturate(screenPxDistance + 0.5);
|
color.a *= saturate(screenPxDistance + 0.5);
|
||||||
color.a *= textureColor.a;
|
color.a *= textureColor.a;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ static void DrawTextWithMarquee(const ImFont* font, float fontSize, const ImVec2
|
||||||
drawList->PopClipRect();
|
drawList->PopClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawTextWithOutline(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 color, const char* text, float outlineSize, ImU32 outlineColor)
|
static void DrawTextWithOutline(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 color, const char* text, float outlineSize, ImU32 outlineColor, uint32_t shaderModifier = IMGUI_SHADER_MODIFIER_NONE)
|
||||||
{
|
{
|
||||||
auto drawList = ImGui::GetForegroundDrawList();
|
auto drawList = ImGui::GetForegroundDrawList();
|
||||||
|
|
||||||
|
|
@ -198,7 +198,13 @@ static void DrawTextWithOutline(const ImFont* font, float fontSize, const ImVec2
|
||||||
drawList->AddText(font, fontSize, pos, outlineColor, text);
|
drawList->AddText(font, fontSize, pos, outlineColor, text);
|
||||||
ResetOutline();
|
ResetOutline();
|
||||||
|
|
||||||
|
if (shaderModifier != IMGUI_SHADER_MODIFIER_NONE)
|
||||||
|
SetShaderModifier(shaderModifier);
|
||||||
|
|
||||||
drawList->AddText(font, fontSize, pos, color, text);
|
drawList->AddText(font, fontSize, pos, color, text);
|
||||||
|
|
||||||
|
if (shaderModifier != IMGUI_SHADER_MODIFIER_NONE)
|
||||||
|
SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawTextWithShadow(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 colour, const char* text, float offset = 2.0f, float radius = 0.4f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255))
|
static void DrawTextWithShadow(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 colour, const char* text, float offset = 2.0f, float radius = 0.4f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255))
|
||||||
|
|
|
||||||
|
|
@ -559,7 +559,7 @@ static void DrawScanlineBars()
|
||||||
// Installer text
|
// Installer text
|
||||||
const std::string &headerText = Localise(g_currentPage == WizardPage::Installing ? "Installer_Header_Installing" : "Installer_Header_Installer");
|
const std::string &headerText = Localise(g_currentPage == WizardPage::Installing ? "Installer_Header_Installing" : "Installer_Header_Installer");
|
||||||
int textAlpha = std::lround(255.0f * ComputeMotionInstaller(g_appearTime, g_disappearTime, TITLE_ANIMATION_TIME, TITLE_ANIMATION_DURATION));
|
int textAlpha = std::lround(255.0f * ComputeMotionInstaller(g_appearTime, g_disappearTime, TITLE_ANIMATION_TIME, TITLE_ANIMATION_DURATION));
|
||||||
DrawTextWithOutline(g_dfsogeistdFont, Scale(42.0f), { Scale(285.0f), Scale(57.0f) }, IM_COL32(255, 195, 0, textAlpha), headerText.c_str(), 4, IM_COL32(0, 0, 0, textAlpha));
|
DrawTextWithOutline(g_dfsogeistdFont, Scale(42.0f), { Scale(285.0f), Scale(57.0f) }, IM_COL32(255, 195, 0, textAlpha), headerText.c_str(), 4, IM_COL32(0, 0, 0, textAlpha), IMGUI_SHADER_MODIFIER_TITLE_BEVEL);
|
||||||
|
|
||||||
// Top bar line
|
// Top bar line
|
||||||
drawList->AddLine
|
drawList->AddLine
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,15 @@ static void DrawScanlineBars()
|
||||||
|
|
||||||
// Options text
|
// Options text
|
||||||
// TODO: localise this.
|
// TODO: localise this.
|
||||||
DrawTextWithOutline(g_dfsogeistdFont, Scale(48.0f), { Scale(122.0f), Scale(56.0f) }, IM_COL32(255, 195, 0, 255), "OPTIONS", 4, IM_COL32_BLACK);
|
DrawTextWithOutline(
|
||||||
|
g_dfsogeistdFont,
|
||||||
|
Scale(48.0f),
|
||||||
|
{ Scale(122.0f), Scale(56.0f) },
|
||||||
|
IM_COL32(255, 190, 33, 255),
|
||||||
|
"OPTIONS",
|
||||||
|
4,
|
||||||
|
IM_COL32_BLACK,
|
||||||
|
IMGUI_SHADER_MODIFIER_TITLE_BEVEL);
|
||||||
|
|
||||||
// Top bar line
|
// Top bar line
|
||||||
drawList->AddLine
|
drawList->AddLine
|
||||||
|
|
@ -397,7 +405,8 @@ static bool DrawCategories()
|
||||||
IM_COL32_WHITE,
|
IM_COL32_WHITE,
|
||||||
GetCategory(i).c_str(),
|
GetCategory(i).c_str(),
|
||||||
3,
|
3,
|
||||||
IM_COL32_BLACK
|
IM_COL32_BLACK,
|
||||||
|
IMGUI_SHADER_MODIFIER_CATEGORY_BEVEL
|
||||||
);
|
);
|
||||||
|
|
||||||
ResetGradient();
|
ResetGradient();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue