Typography improvements
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
"type": "float",
|
||||
"default": 0.42,
|
||||
"min": 0.1,
|
||||
"max": 1.5,
|
||||
"max": 3,
|
||||
"step": 0.01
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user