From d041e2ba3059c396251dfdd9a50fb0810d1b4f06 Mon Sep 17 00:00:00 2001 From: "Skyth (Asilkan)" <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Sat, 25 Jan 2025 18:28:43 +0300 Subject: [PATCH] Fix ImGui procedural filtering. (#188) --- UnleashedRecomp/gpu/shader/imgui_ps.hlsl | 14 +++++++------- UnleashedRecomp/ui/installer_wizard.cpp | 4 ++-- UnleashedRecomp/ui/options_menu.cpp | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/UnleashedRecomp/gpu/shader/imgui_ps.hlsl b/UnleashedRecomp/gpu/shader/imgui_ps.hlsl index c105258..6750e62 100644 --- a/UnleashedRecomp/gpu/shader/imgui_ps.hlsl +++ b/UnleashedRecomp/gpu/shader/imgui_ps.hlsl @@ -60,17 +60,17 @@ float4 SampleLinear(float2 uvTexspace) } float4 PixelAntialiasing(float2 uvTexspace) -{ - float2 seam = floor(uvTexspace + 0.5); - uvTexspace = (uvTexspace - seam) / fwidth(uvTexspace) + seam; - uvTexspace = clamp(uvTexspace, seam - 0.5, seam + 0.5); - +{ if ((g_PushConstants.InverseDisplaySize.y / g_PushConstants.InverseDisplaySize.x) >= (4.0 / 3.0)) uvTexspace *= g_PushConstants.InverseDisplaySize.y * 720.0f; else uvTexspace *= g_PushConstants.InverseDisplaySize.x * 960.0f; + + float2 seam = floor(uvTexspace + 0.5); + uvTexspace = (uvTexspace - seam) / fwidth(uvTexspace) + seam; + uvTexspace = clamp(uvTexspace, seam - 0.5, seam + 0.5); - return SampleLinear(uvTexspace); + return SampleLinear(uvTexspace - 0.5); } float median(float r, float g, float b) @@ -81,7 +81,7 @@ float median(float r, float g, float b) float4 main(in Interpolators interpolators) : SV_Target { float4 color = interpolators.Color; - color *= PixelAntialiasing(interpolators.Position.xy - (g_PushConstants.ProceduralOrigin + 0.5)); + color *= PixelAntialiasing(interpolators.Position.xy - g_PushConstants.ProceduralOrigin); if (g_PushConstants.Texture2DDescriptorIndex != 0) { diff --git a/UnleashedRecomp/ui/installer_wizard.cpp b/UnleashedRecomp/ui/installer_wizard.cpp index b3e4e87..ff94832 100644 --- a/UnleashedRecomp/ui/installer_wizard.cpp +++ b/UnleashedRecomp/ui/installer_wizard.cpp @@ -639,8 +639,8 @@ static void DrawDescriptionContainer() auto drawList = ImGui::GetForegroundDrawList(); auto fontSize = Scale(26.0f); - ImVec2 descriptionMin = { g_aspectRatioOffsetX + Scale(CONTAINER_X), g_aspectRatioOffsetY + Scale(CONTAINER_Y) }; - ImVec2 descriptionMax = { g_aspectRatioOffsetX + Scale(CONTAINER_X + CONTAINER_WIDTH), g_aspectRatioOffsetY + Scale(CONTAINER_Y + CONTAINER_HEIGHT) }; + ImVec2 descriptionMin = { round(g_aspectRatioOffsetX + Scale(CONTAINER_X)), round(g_aspectRatioOffsetY + Scale(CONTAINER_Y)) }; + ImVec2 descriptionMax = { round(g_aspectRatioOffsetX + Scale(CONTAINER_X + CONTAINER_WIDTH)), round(g_aspectRatioOffsetY + Scale(CONTAINER_Y + CONTAINER_HEIGHT)) }; SetProceduralOrigin(descriptionMin); DrawContainer(descriptionMin, descriptionMax, true); diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 056087c..4a8a830 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1230,17 +1230,17 @@ void OptionsMenu::Draw() float totalGridCount = settingsGridCount + paddingGridCount + infoGridCount; float offsetX = (1280.0f - ((GRID_SIZE * totalGridCount) - 1)) / 2.0f; - float minY = g_aspectRatioOffsetY + Scale(CONTAINER_POS_Y); - float maxY = g_aspectRatioOffsetY + Scale((720.0f - CONTAINER_POS_Y + 1.0f)); + float minY = round(g_aspectRatioOffsetY + Scale(CONTAINER_POS_Y)); + float maxY = round(g_aspectRatioOffsetY + Scale((720.0f - CONTAINER_POS_Y + 1.0f))); DrawSettingsPanel( - { g_aspectRatioOffsetX + Scale(offsetX), minY }, - { g_aspectRatioOffsetX + Scale(offsetX + settingsGridCount * GRID_SIZE), maxY } + { round(g_aspectRatioOffsetX + Scale(offsetX)), minY }, + { round(g_aspectRatioOffsetX + Scale(offsetX + settingsGridCount * GRID_SIZE)), maxY } ); DrawInfoPanel( - { g_aspectRatioOffsetX + Scale(offsetX + (settingsGridCount + paddingGridCount) * GRID_SIZE), minY }, - { g_aspectRatioOffsetX + Scale(offsetX + totalGridCount * GRID_SIZE), maxY } + { round(g_aspectRatioOffsetX + Scale(offsetX + (settingsGridCount + paddingGridCount) * GRID_SIZE)), minY }, + { round(g_aspectRatioOffsetX + Scale(offsetX + totalGridCount * GRID_SIZE)), maxY } ); if (g_isStage)