Typography improvements
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 1m31s
CI / Windows Release Package (push) Successful in 2m20s

This commit is contained in:
2026-05-06 13:16:02 +10:00
parent 3dc7af6fc0
commit e59677c212
5 changed files with 126 additions and 129 deletions

View File

@@ -10,6 +10,12 @@ float4 compositeOver(float4 baseColor, float4 overColor)
return float4(outRgb, outAlpha);
}
float sdfCoverage(float2 uv, float edge, float aa)
{
float distance = sampleTitleText(uv);
return smoothstep(edge - aa, edge + aa, distance);
}
float4 shadeVideo(ShaderContext context)
{
float2 resolution = max(context.outputResolution, float2(1.0, 1.0));
@@ -19,21 +25,26 @@ float4 shadeVideo(ShaderContext context)
float2 textUv = (context.uv - position) / safeTextSize;
bool insideTextRect = textUv.x >= 0.0 && textUv.x <= 1.0 && textUv.y >= 0.0 && textUv.y <= 1.0;
float mask = insideTextRect ? sampleTitleText(textUv) : 0.0;
float edge = 0.02;
float aa = max(fwidth(mask) * 1.5, 0.002);
float fill = smoothstep(edge - aa, edge + aa, mask);
float shadowRadius = min((outlineWidth + softness) * 0.025, 0.018);
float shadow = 0.0;
if (shadowRadius > 0.0001)
{
shadow = max(shadow, sampleTitleText(textUv + float2(shadowRadius, shadowRadius)));
shadow = max(shadow, sampleTitleText(textUv + float2(-shadowRadius, shadowRadius)));
shadow = max(shadow, sampleTitleText(textUv + float2(shadowRadius, -shadowRadius)));
shadow = max(shadow, sampleTitleText(textUv + float2(-shadowRadius, -shadowRadius)));
}
shadow = smoothstep(edge - aa, edge + aa, shadow) * (0.35 + softness);
float outlineAlpha = saturate(shadow * (1.0 - fill)) * outlineColor.a;
float distance = insideTextRect ? sampleTitleText(textUv) : 0.0;
float edge = 0.5;
float aa = max(fwidth(distance) * (1.75 + softness * 5.0), 0.0025);
float2 pixelTextUv = (1.0 / resolution) / safeTextSize;
float2 sampleOffset = pixelTextUv * 0.38;
float fill = (
sdfCoverage(textUv, edge, aa) * 2.0 +
sdfCoverage(textUv + float2(sampleOffset.x, sampleOffset.y), edge, aa) +
sdfCoverage(textUv + float2(-sampleOffset.x, sampleOffset.y), edge, aa) +
sdfCoverage(textUv + float2(sampleOffset.x, -sampleOffset.y), edge, aa) +
sdfCoverage(textUv + float2(-sampleOffset.x, -sampleOffset.y), edge, aa)) / 6.0;
float outlineDistance = outlineWidth * 0.16;
float outlineEdge = edge - outlineDistance;
float outline = (
sdfCoverage(textUv, outlineEdge, aa) * 2.0 +
sdfCoverage(textUv + float2(sampleOffset.x, sampleOffset.y), outlineEdge, aa) +
sdfCoverage(textUv + float2(-sampleOffset.x, sampleOffset.y), outlineEdge, aa) +
sdfCoverage(textUv + float2(sampleOffset.x, -sampleOffset.y), outlineEdge, aa) +
sdfCoverage(textUv + float2(-sampleOffset.x, -sampleOffset.y), outlineEdge, aa)) / 6.0;
float outlineAlpha = saturate(outline - fill) * outlineColor.a;
float fillAlpha = fill * fillColor.a;
float textAlpha = max(fillAlpha, outlineAlpha);
if (textAlpha <= 0.0001)