V1 text, needs improvements
Some checks failed
CI / Native Windows Build And Tests (pull_request) Failing after 18s
CI / React UI Build (pull_request) Has been cancelled
CI / Windows Release Package (pull_request) Has been cancelled

This commit is contained in:
2026-05-05 23:57:02 +10:00
parent 6ce09c0e9c
commit 7e4ab5cbd8
4 changed files with 50 additions and 11 deletions

View File

@@ -57,6 +57,15 @@
"min": 0.0,
"max": 0.5,
"step": 0.01
},
{
"id": "softness",
"label": "Softness",
"type": "float",
"default": 0.04,
"min": 0.0,
"max": 0.3,
"step": 0.01
}
]
}

View File

@@ -20,18 +20,27 @@ float4 shadeVideo(ShaderContext context)
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.5;
float aa = max(fwidth(mask) * 1.5, 0.006);
float outlineAmount = min(outlineWidth * 0.25, 0.24);
float edge = 0.02;
float aa = max(fwidth(mask) * 1.5, 0.002);
float fill = smoothstep(edge - aa, edge + aa, mask);
float outlineField = smoothstep(edge - outlineAmount - aa, edge - outlineAmount + aa, mask);
float outline = saturate(outlineField - fill);
float textAlpha = max(fill * fillColor.a, outline * outlineColor.a);
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 fillAlpha = fill * fillColor.a;
float textAlpha = max(fillAlpha, outlineAlpha);
if (textAlpha <= 0.0001)
return context.sourceColor;
float4 base = context.sourceColor;
float4 outlineLayer = float4(outlineColor.rgb * outlineColor.a, outline * outlineColor.a);
float4 fillLayer = float4(fillColor.rgb * fillColor.a, fill * fillColor.a);
float4 outlineLayer = float4(outlineColor.rgb * outlineAlpha, outlineAlpha);
float4 fillLayer = float4(fillColor.rgb * fillAlpha, fillAlpha);
return saturate(compositeOver(compositeOver(base, outlineLayer), fillLayer));
}