Initial font work

This commit is contained in:
2026-05-05 23:18:50 +10:00
parent fd0ebb8d40
commit 3e8b472f74
20 changed files with 873 additions and 84 deletions

View File

@@ -0,0 +1,28 @@
float alphaOver(float baseAlpha, float overAlpha)
{
return overAlpha + baseAlpha * (1.0 - overAlpha);
}
float4 compositeOver(float4 baseColor, float4 overColor)
{
float outAlpha = alphaOver(baseColor.a, overColor.a);
float3 outRgb = overColor.rgb + baseColor.rgb * (1.0 - overColor.a);
return float4(outRgb, outAlpha);
}
float4 shadeVideo(ShaderContext context)
{
float2 resolution = max(context.outputResolution, float2(1.0, 1.0));
float aspect = resolution.x / resolution.y;
float2 textSize = float2(0.72 * scale, 0.09 * scale * aspect);
float2 textUv = (context.uv - position) / max(textSize, float2(0.0001, 0.0001));
float mask = sampleTitleText(textUv);
float fill = smoothstep(0.48, 0.54, mask);
float outline = smoothstep(0.48 - outlineWidth, 0.54 - outlineWidth, mask);
float4 base = context.sourceColor;
float4 outlineLayer = float4(outlineColor.rgb * outlineColor.a, outline * outlineColor.a);
float4 fillLayer = float4(fillColor.rgb * fillColor.a, fill * fillColor.a);
return saturate(compositeOver(compositeOver(base, outlineLayer), fillLayer));
}