mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 12:51:42 +00:00
Fix regular image display.
This commit is contained in:
parent
bdebd6408f
commit
1282c1384e
3 changed files with 24 additions and 8 deletions
|
|
@ -195,14 +195,15 @@ static bool FontBuilder_Build(ImFontAtlas* atlas)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& glyph : glyphs)
|
for (auto& glyph : glyphs)
|
||||||
glyph.edgeColoring(&msdfgen::edgeColoringInkTrap, 3.0, 0);
|
glyph.edgeColoring(&msdfgen::edgeColoringByDistance, 3.0, 0);
|
||||||
|
|
||||||
for (auto& customRect : atlas->CustomRects)
|
for (auto& customRect : atlas->CustomRects)
|
||||||
customRects.emplace_back(0, 0, int(customRect.Width), int(customRect.Height));
|
customRects.emplace_back(0, 0, int(customRect.Width), int(customRect.Height));
|
||||||
|
|
||||||
TightAtlasPacker packer;
|
TightAtlasPacker packer;
|
||||||
packer.spacing = 1;
|
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.miterLimit = 1.0;
|
||||||
packer.pxRange = 4.0;
|
packer.pxRange = 4.0;
|
||||||
packer.pack(glyphs.data(), glyphs.size(), customRects.data(), customRects.size());
|
packer.pack(glyphs.data(), glyphs.size(), customRects.data(), customRects.size());
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,15 @@ float4 PixelAntialiasing(float2 uvTexspace)
|
||||||
return SampleLinear(uvTexspace);
|
return SampleLinear(uvTexspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint GetTexture2DDescriptorIndex()
|
||||||
|
{
|
||||||
|
return g_PushConstants.Texture2DDescriptorIndex & 0x7FFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
float ComputeScreenPixelRange(float2 texCoord)
|
float ComputeScreenPixelRange(float2 texCoord)
|
||||||
{
|
{
|
||||||
uint width, height;
|
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 unitRange = 4.0 / float2(width, height);
|
||||||
float2 screenTextureSize = 1.0 / fwidth(texCoord);
|
float2 screenTextureSize = 1.0 / fwidth(texCoord);
|
||||||
|
|
@ -95,11 +100,18 @@ float4 main(in Interpolators interpolators) : SV_Target
|
||||||
|
|
||||||
if (g_PushConstants.Texture2DDescriptorIndex != 0)
|
if (g_PushConstants.Texture2DDescriptorIndex != 0)
|
||||||
{
|
{
|
||||||
float4 msd = g_Texture2DDescriptorHeap[g_PushConstants.Texture2DDescriptorIndex].Sample(g_SamplerDescriptorHeap[0], interpolators.UV);
|
float4 texture = g_Texture2DDescriptorHeap[GetTexture2DDescriptorIndex()].Sample(g_SamplerDescriptorHeap[0], interpolators.UV);
|
||||||
float sd = median(msd.r, msd.g, msd.b) - 0.5;
|
if ((g_PushConstants.Texture2DDescriptorIndex & 0x80000000) != 0)
|
||||||
|
{
|
||||||
|
float sd = median(texture.r, texture.g, texture.b) - 0.5;
|
||||||
float screenPixelDistance = ComputeScreenPixelRange(interpolators.UV) * sd;
|
float screenPixelDistance = ComputeScreenPixelRange(interpolators.UV) * sd;
|
||||||
color.a *= saturate(screenPixelDistance + 0.5);
|
color.a *= saturate(screenPixelDistance + 0.5);
|
||||||
color.a *= msd.a;
|
color.a *= texture.a;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
color *= texture;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_MARQUEE_FADE)
|
if (g_PushConstants.ShaderModifier == IMGUI_SHADER_MODIFIER_MARQUEE_FADE)
|
||||||
|
|
|
||||||
|
|
@ -1953,6 +1953,9 @@ static void ProcDrawImGui(const RenderCommand& cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptorIndex = texture->descriptorIndex;
|
descriptorIndex = texture->descriptorIndex;
|
||||||
|
|
||||||
|
if (texture == g_imFontTexture.get())
|
||||||
|
descriptorIndex |= 0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
commandList->setGraphicsPushConstants(0, &descriptorIndex, offsetof(ImGuiPushConstants, texture2DDescriptorIndex), sizeof(descriptorIndex));
|
commandList->setGraphicsPushConstants(0, &descriptorIndex, offsetof(ImGuiPushConstants, texture2DDescriptorIndex), sizeof(descriptorIndex));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue