mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-10-30 07:11:05 +00:00
Allow specifying all corners for ImGui gradients. (#247)
This commit is contained in:
parent
70f042d11f
commit
21c1d36836
6 changed files with 25 additions and 9 deletions
|
|
@ -32,8 +32,10 @@ union ImGuiCallbackData
|
|||
{
|
||||
float boundsMin[2];
|
||||
float boundsMax[2];
|
||||
uint32_t gradientTop;
|
||||
uint32_t gradientBottom;
|
||||
uint32_t gradientTopLeft;
|
||||
uint32_t gradientTopRight;
|
||||
uint32_t gradientBottomRight;
|
||||
uint32_t gradientBottomLeft;
|
||||
} setGradient;
|
||||
|
||||
struct
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ struct PushConstants
|
|||
{
|
||||
float2 BoundsMin;
|
||||
float2 BoundsMax;
|
||||
uint GradientTop;
|
||||
uint GradientBottom;
|
||||
uint GradientTopLeft;
|
||||
uint GradientTopRight;
|
||||
uint GradientBottomRight;
|
||||
uint GradientBottomLeft;
|
||||
uint ShaderModifier;
|
||||
uint Texture2DDescriptorIndex;
|
||||
float2 InverseDisplaySize;
|
||||
|
|
|
|||
|
|
@ -165,7 +165,9 @@ float4 main(in Interpolators interpolators) : SV_Target
|
|||
}
|
||||
else
|
||||
{
|
||||
color *= lerp(DecodeColor(g_PushConstants.GradientTop), DecodeColor(g_PushConstants.GradientBottom), smoothstep(0.0, 1.0, factor.y));
|
||||
float4 top = lerp(DecodeColor(g_PushConstants.GradientTopLeft), DecodeColor(g_PushConstants.GradientTopRight), smoothstep(0.0, 1.0, factor.x));
|
||||
float4 bottom = lerp(DecodeColor(g_PushConstants.GradientBottomLeft), DecodeColor(g_PushConstants.GradientBottomRight), smoothstep(0.0, 1.0, factor.x));
|
||||
color *= lerp(top, bottom, smoothstep(0.0, 1.0, factor.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1196,8 +1196,10 @@ struct ImGuiPushConstants
|
|||
{
|
||||
ImVec2 boundsMin{};
|
||||
ImVec2 boundsMax{};
|
||||
ImU32 gradientTop{};
|
||||
ImU32 gradientBottom{};
|
||||
ImU32 gradientTopLeft{};
|
||||
ImU32 gradientTopRight{};
|
||||
ImU32 gradientBottomRight{};
|
||||
ImU32 gradientBottomLeft{};
|
||||
uint32_t shaderModifier{};
|
||||
uint32_t texture2DDescriptorIndex{};
|
||||
ImVec2 inverseDisplaySize{};
|
||||
|
|
|
|||
|
|
@ -23,14 +23,21 @@ void InitImGuiUtils()
|
|||
}
|
||||
|
||||
void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 top, ImU32 bottom)
|
||||
{
|
||||
SetGradient(min, max, top, top, bottom, bottom);
|
||||
}
|
||||
|
||||
void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 topLeft, ImU32 topRight, ImU32 bottomRight, ImU32 bottomLeft)
|
||||
{
|
||||
auto callbackData = AddImGuiCallback(ImGuiCallback::SetGradient);
|
||||
callbackData->setGradient.boundsMin[0] = min.x;
|
||||
callbackData->setGradient.boundsMin[1] = min.y;
|
||||
callbackData->setGradient.boundsMax[0] = max.x;
|
||||
callbackData->setGradient.boundsMax[1] = max.y;
|
||||
callbackData->setGradient.gradientTop = top;
|
||||
callbackData->setGradient.gradientBottom = bottom;
|
||||
callbackData->setGradient.gradientTopLeft = topLeft;
|
||||
callbackData->setGradient.gradientTopRight = topRight;
|
||||
callbackData->setGradient.gradientBottomRight = bottomRight;
|
||||
callbackData->setGradient.gradientBottomLeft = bottomLeft;
|
||||
}
|
||||
|
||||
void ResetGradient()
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ struct Paragraph {
|
|||
void InitImGuiUtils();
|
||||
|
||||
void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 top, ImU32 bottom);
|
||||
void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 topLeft, ImU32 topRight, ImU32 bottomRight, ImU32 bottomLeft);
|
||||
void ResetGradient();
|
||||
void SetShaderModifier(uint32_t shaderModifier);
|
||||
void SetOrigin(ImVec2 origin);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue