[gpu] Use pow(2, brightness-0.5) for stem darkening

Replace boolean light_on_dark with continuous brightness-driven
exponent. pow(2, b-0.5) gives sqrt(2)≈1.414 for white text
(thin) and 1/sqrt(2)≈0.707 for black text (fatten), perfectly
symmetric around 1.0 at 50% gray.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Behdad EsfahbodandClaude Opus 4.6 committed 2026-03-30 19:25:31 -06:00
1 parent b9e864e9e7
commit 9e2828622c
2 files changed
+4 -7

No files matched your search

+2 -3
View File
@@ -56,9 +56,8 @@ void main ()
{
float ppem = 1.0 / max (fwidth (v_texcoord).x, fwidth (v_texcoord).y);
float size_factor = smoothstep (8.0, 48.0, ppem);
bool light_on_dark = dot (u_foreground.rgb, vec3 (1.0)) > 1.5;
float stem_exp = light_on_dark ? mix (1.4, 1.0, size_factor)
: mix (0.7, 1.0, size_factor);
float brightness = dot (u_foreground.rgb, vec3 (1.0 / 3.0));
float stem_exp = mix (pow (2.0, brightness - 0.5), 1.0, size_factor);
coverage = pow (coverage, stem_exp);
}
+2 -4
View File
@@ -108,10 +108,8 @@ struct VertexOutput {
if (u.stem_darkening > 0.0) {
let ppem = 1.0 / max (fwidth (in.texcoord).x, fwidth (in.texcoord).y);
let size_factor = smoothstep (8.0, 48.0, ppem);
let light_on_dark = dot (u.foreground.rgb, vec3f (1.0)) > 1.5;
var stem_exp: f32;
if (light_on_dark) { stem_exp = mix (1.4, 1.0, size_factor); }
else { stem_exp = mix (0.7, 1.0, size_factor); }
let brightness = dot (u.foreground.rgb, vec3f (1.0 / 3.0));
let stem_exp = mix (pow (2.0, brightness - 0.5), 1.0, size_factor);
coverage = pow (coverage, stem_exp);
}