Apply symbol shader changes from JS for Metal, Vulkan, and OpenGL (#3873)

This commit is contained in:
Tim Sylvester
2025-10-15 13:14:06 -07:00
committed by GitHub
parent 54565f081b
commit 18e51caa22
13 changed files with 273 additions and 29 deletions

View File

@@ -57,16 +57,22 @@ void main() {
lowp vec4 color = fill_color;
highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
lowp float buff = (256.0 - 64.0) / 256.0;
lowp float inner_edge = (256.0 - 64.0) / 256.0;
if (u_is_halo) {
color = halo_color;
gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
buff = (6.0 - halo_width / fontScale) / SDF_PX;
inner_edge = inner_edge + gamma * gamma_scale;
}
lowp float dist = texture(u_texture, tex).a;
highp float gamma_scaled = gamma * gamma_scale;
highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
highp float alpha = smoothstep(inner_edge - gamma_scaled, inner_edge + gamma_scaled, dist);
if (u_is_halo) {
// When drawing halos, we want the inside of the halo to be transparent as well
// in case the text fill is transparent.
lowp float halo_edge = (6.0 - halo_width / fontScale) / SDF_PX;
alpha = min(smoothstep(halo_edge - gamma_scaled, halo_edge + gamma_scaled, dist), 1.0 - alpha);
}
fragColor = color * (alpha * opacity * fade_opacity);

View File

@@ -74,16 +74,22 @@ void main() {
lowp vec4 color = fill_color;
highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
lowp float buff = (256.0 - 64.0) / 256.0;
lowp float inner_edge = (256.0 - 64.0) / 256.0;
if (u_is_halo) {
color = halo_color;
gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
buff = (6.0 - halo_width / fontScale) / SDF_PX;
inner_edge = inner_edge + gamma * gamma_scale;
}
lowp float dist = texture(u_texture, tex).a;
highp float gamma_scaled = gamma * gamma_scale;
highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
highp float alpha = smoothstep(inner_edge - gamma_scaled, inner_edge + gamma_scaled, dist);
if (u_is_halo) {
// When drawing halos, we want the inside of the halo to be transparent as well
// in case the text fill is transparent.
lowp float halo_edge = (6.0 - halo_width / fontScale) / SDF_PX;
alpha = min(smoothstep(halo_edge - gamma_scaled, halo_edge + gamma_scaled, dist), 1.0 - alpha);
}
fragColor = color * (alpha * opacity * fade_opacity);