mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 04:41:39 +00:00
Implement shader modifier for options title rectangle.
This commit is contained in:
parent
9fa20ec678
commit
bd0ec78cf5
3 changed files with 28 additions and 2 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
#define IMGUI_SHADER_MODIFIER_GRAYSCALE 6
|
#define IMGUI_SHADER_MODIFIER_GRAYSCALE 6
|
||||||
#define IMGUI_SHADER_MODIFIER_TITLE_BEVEL 7
|
#define IMGUI_SHADER_MODIFIER_TITLE_BEVEL 7
|
||||||
#define IMGUI_SHADER_MODIFIER_CATEGORY_BEVEL 8
|
#define IMGUI_SHADER_MODIFIER_CATEGORY_BEVEL 8
|
||||||
|
#define IMGUI_SHADER_MODIFIER_RECTANGLE_BEVEL 9
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,8 +146,28 @@ float4 main(in Interpolators interpolators) : SV_Target
|
||||||
else if (any(g_PushConstants.BoundsMin != g_PushConstants.BoundsMax))
|
else if (any(g_PushConstants.BoundsMin != g_PushConstants.BoundsMax))
|
||||||
{
|
{
|
||||||
float2 factor = saturate((interpolators.Position.xy - g_PushConstants.BoundsMin) / (g_PushConstants.BoundsMax - g_PushConstants.BoundsMin));
|
float2 factor = saturate((interpolators.Position.xy - g_PushConstants.BoundsMin) / (g_PushConstants.BoundsMax - g_PushConstants.BoundsMin));
|
||||||
|
|
||||||
|
if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_RECTANGLE_BEVEL)
|
||||||
|
{
|
||||||
|
float bevelSize = 0.9;
|
||||||
|
|
||||||
|
float shadow = saturate((factor.x - bevelSize) / (1.0 - bevelSize));
|
||||||
|
shadow = max(shadow, saturate((factor.y - bevelSize) / (1.0 - bevelSize)));
|
||||||
|
|
||||||
|
float rim = saturate((1.0 - factor.x - bevelSize) / (1.0 - bevelSize));
|
||||||
|
rim = max(rim, saturate((1.0 - factor.y - bevelSize) / (1.0 - bevelSize)));
|
||||||
|
|
||||||
|
float3 rimColor = float3(1, 0.8, 0.29);
|
||||||
|
float3 shadowColor = float3(0.84, 0.57, 0);
|
||||||
|
|
||||||
|
color.rgb = lerp(color.rgb, rimColor, smoothstep(0.0, 1.0, rim));
|
||||||
|
color.rgb = lerp(color.rgb, shadowColor, smoothstep(0.0, 1.0, shadow));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
color *= lerp(DecodeColor(g_PushConstants.GradientTop), DecodeColor(g_PushConstants.GradientBottom), smoothstep(0.0, 1.0, factor.y));
|
color *= lerp(DecodeColor(g_PushConstants.GradientTop), DecodeColor(g_PushConstants.GradientBottom), smoothstep(0.0, 1.0, factor.y));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_GRAYSCALE)
|
if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_GRAYSCALE)
|
||||||
color.rgb = dot(color.rgb, float3(0.2126, 0.7152, 0.0722));
|
color.rgb = dot(color.rgb, float3(0.2126, 0.7152, 0.0722));
|
||||||
|
|
|
||||||
|
|
@ -200,8 +200,13 @@ static void DrawTitle()
|
||||||
|
|
||||||
drawList->AddRectFilled(rectOutlineMin, rectOutlineMax, IM_COL32(0, 0, 0, 255 * rectAlphaMotion), Scale(5));
|
drawList->AddRectFilled(rectOutlineMin, rectOutlineMax, IM_COL32(0, 0, 0, 255 * rectAlphaMotion), Scale(5));
|
||||||
|
|
||||||
// TODO: apply bevel to this square (may require a new shader modifier, existing ones don't work).
|
SetShaderModifier(IMGUI_SHADER_MODIFIER_RECTANGLE_BEVEL);
|
||||||
|
SetGradient(rectMin, rectMax, IM_COL32_WHITE, IM_COL32_WHITE);
|
||||||
|
|
||||||
drawList->AddRectFilled(rectMin, rectMax, IM_COL32(255, 188, 0, 255 * rectAlphaMotion));
|
drawList->AddRectFilled(rectMin, rectMax, IM_COL32(255, 188, 0, 255 * rectAlphaMotion));
|
||||||
|
|
||||||
|
ResetGradient();
|
||||||
|
SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The flash gets rendered after the rectangle in the original game.
|
// The flash gets rendered after the rectangle in the original game.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue