1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Fix MSDF outline size clamping.

This commit is contained in:
Pāvels Nadtočajevs
2025-08-19 08:28:33 +03:00
parent 8ebf8ae23c
commit 6a3941b5d9
3 changed files with 3 additions and 3 deletions

View File

@@ -609,7 +609,7 @@ void main() {
float d = msdf_median(msdf_sample.r, msdf_sample.g, msdf_sample.b); float d = msdf_median(msdf_sample.r, msdf_sample.g, msdf_sample.b);
if (outline_thickness > 0.0) { if (outline_thickness > 0.0) {
float cr = clamp(outline_thickness, 0.0, px_range / 2.0) / px_range; float cr = clamp(outline_thickness, 0.0, (px_range / 2.0) - 1.0) / px_range;
d = min(d, msdf_sample.a); d = min(d, msdf_sample.a);
float a = clamp((d - 0.5 + cr) * px_size + 0.5, 0.0, 1.0); float a = clamp((d - 0.5 + cr) * px_size + 0.5, 0.0, 1.0);
color.a = a * color.a; color.a = a * color.a;

View File

@@ -1638,7 +1638,7 @@ void fragment() {)";
float px_size = max(0.5 * dot(msdf_size, dest_size), 1.0); float px_size = max(0.5 * dot(msdf_size, dest_size), 1.0);
float d = msdf_median(albedo_tex.r, albedo_tex.g, albedo_tex.b); float d = msdf_median(albedo_tex.r, albedo_tex.g, albedo_tex.b);
if (msdf_outline_size > 0.0) { if (msdf_outline_size > 0.0) {
float cr = clamp(msdf_outline_size, 0.0, msdf_pixel_range / 2.0) / msdf_pixel_range; float cr = clamp(msdf_outline_size, 0.0, (msdf_pixel_range / 2.0) - 1.0) / msdf_pixel_range;
d = min(d, albedo_tex.a); d = min(d, albedo_tex.a);
albedo_tex.a = clamp((d - 0.5 + cr) * px_size + 0.5, 0.0, 1.0); albedo_tex.a = clamp((d - 0.5 + cr) * px_size + 0.5, 0.0, 1.0);
} else { } else {

View File

@@ -516,7 +516,7 @@ void main() {
float d = msdf_median(msdf_sample.r, msdf_sample.g, msdf_sample.b); float d = msdf_median(msdf_sample.r, msdf_sample.g, msdf_sample.b);
if (outline_thickness > 0) { if (outline_thickness > 0) {
float cr = clamp(outline_thickness, 0.0, px_range / 2) / px_range; float cr = clamp(outline_thickness, 0.0, (px_range / 2.0) - 1.0) / px_range;
d = min(d, msdf_sample.a); d = min(d, msdf_sample.a);
float a = clamp((d - 0.5 + cr) * px_size + 0.5, 0.0, 1.0); float a = clamp((d - 0.5 + cr) * px_size + 0.5, 0.0, 1.0);
color.a = a * color.a; color.a = a * color.a;