diff --git a/UnleashedRecomp/gpu/imgui_font_builder.cpp b/UnleashedRecomp/gpu/imgui_font_builder.cpp index 7ab1e9d8..334143bc 100644 --- a/UnleashedRecomp/gpu/imgui_font_builder.cpp +++ b/UnleashedRecomp/gpu/imgui_font_builder.cpp @@ -195,14 +195,15 @@ static bool FontBuilder_Build(ImFontAtlas* atlas) } for (auto& glyph : glyphs) - glyph.edgeColoring(&msdfgen::edgeColoringInkTrap, 3.0, 0); + glyph.edgeColoring(&msdfgen::edgeColoringByDistance, 3.0, 0); for (auto& customRect : atlas->CustomRects) customRects.emplace_back(0, 0, int(customRect.Width), int(customRect.Height)); TightAtlasPacker packer; packer.spacing = 1; - packer.minScale = 16.0; + packer.dimensionsConstraint = msdf_atlas::DimensionsConstraint::POWER_OF_TWO_RECTANGLE; + packer.minScale = 24.0; packer.miterLimit = 1.0; packer.pxRange = 4.0; packer.pack(glyphs.data(), glyphs.size(), customRects.data(), customRects.size()); diff --git a/UnleashedRecomp/gpu/shader/imgui_ps.hlsl b/UnleashedRecomp/gpu/shader/imgui_ps.hlsl index 1db4f777..8bdacb5e 100644 --- a/UnleashedRecomp/gpu/shader/imgui_ps.hlsl +++ b/UnleashedRecomp/gpu/shader/imgui_ps.hlsl @@ -73,10 +73,15 @@ float4 PixelAntialiasing(float2 uvTexspace) return SampleLinear(uvTexspace); } +uint GetTexture2DDescriptorIndex() +{ + return g_PushConstants.Texture2DDescriptorIndex & 0x7FFFFFFF; +} + float ComputeScreenPixelRange(float2 texCoord) { uint width, height; - g_Texture2DDescriptorHeap[g_PushConstants.Texture2DDescriptorIndex].GetDimensions(width, height); + g_Texture2DDescriptorHeap[GetTexture2DDescriptorIndex()].GetDimensions(width, height); float2 unitRange = 4.0 / float2(width, height); float2 screenTextureSize = 1.0 / fwidth(texCoord); @@ -95,11 +100,18 @@ float4 main(in Interpolators interpolators) : SV_Target if (g_PushConstants.Texture2DDescriptorIndex != 0) { - float4 msd = g_Texture2DDescriptorHeap[g_PushConstants.Texture2DDescriptorIndex].Sample(g_SamplerDescriptorHeap[0], interpolators.UV); - float sd = median(msd.r, msd.g, msd.b) - 0.5; - float screenPixelDistance = ComputeScreenPixelRange(interpolators.UV) * sd; - color.a *= saturate(screenPixelDistance + 0.5); - color.a *= msd.a; + float4 texture = g_Texture2DDescriptorHeap[GetTexture2DDescriptorIndex()].Sample(g_SamplerDescriptorHeap[0], interpolators.UV); + if ((g_PushConstants.Texture2DDescriptorIndex & 0x80000000) != 0) + { + float sd = median(texture.r, texture.g, texture.b) - 0.5; + float screenPixelDistance = ComputeScreenPixelRange(interpolators.UV) * sd; + color.a *= saturate(screenPixelDistance + 0.5); + color.a *= texture.a; + } + else + { + color *= texture; + } } if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_MARQUEE_FADE) diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index ee6af88e..cc97673e 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -1953,6 +1953,9 @@ static void ProcDrawImGui(const RenderCommand& cmd) } descriptorIndex = texture->descriptorIndex; + + if (texture == g_imFontTexture.get()) + descriptorIndex |= 0x80000000; } commandList->setGraphicsPushConstants(0, &descriptorIndex, offsetof(ImGuiPushConstants, texture2DDescriptorIndex), sizeof(descriptorIndex));