Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.4 dev7] Fonts using Multichannel Signed Distance Fields break when used in Label3D #100726

Closed
AbsoluteMoose opened this issue Dec 22, 2024 · 1 comment

Comments

@AbsoluteMoose
Copy link

AbsoluteMoose commented Dec 22, 2024

Tested versions

Reproducible in: 4.4 dev7
Not reproducible in: 4.4 dev6 and earlier

System information

Godot v4.4.dev7.mono - Windows 10 (build 19045) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4070 Ti (NVIDIA; 32.0.15.6590) - 13th Gen Intel(R) Core(TM) i7-13700K (24 threads)

Issue description

In Label3D nodes using a font with Multi Channel Signed Distance Fields turned on in import or project settings, all characters show up as grey boxes.

The following error also appears in the Output tab:

ERROR: :53 - Unknown identifier in expression: 'albedo_texture_size'.
ERROR: Shader compilation failed.
--Main Shader--
1 | // NOTE: Shader automatically converted from Godot Engine 4.4.dev7.mono's StandardMaterial3D.
2 |
3 | shader_type spatial;
4 | render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;
5 |
6 | uniform vec4 albedo : source_color;
7 | uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
8 |
9 | uniform float msdf_pixel_range : hint_range(1.0, 100.0, 1.0);
10 | uniform float msdf_outline_size : hint_range(0.0, 250.0, 1.0);
11 | uniform float alpha_scissor_threshold : hint_range(0.0, 1.0, 0.001);
12 | uniform float point_size : hint_range(0.1, 128.0, 0.1);
13 |
14 | uniform float roughness : hint_range(0.0, 1.0);
15 | uniform sampler2D texture_metallic : hint_default_white, filter_linear_mipmap, repeat_enable;
16 | uniform vec4 metallic_texture_channel;
17 | uniform sampler2D texture_roughness : hint_roughness_r, filter_linear_mipmap, repeat_enable;
18 |
19 | uniform float specular : hint_range(0.0, 1.0, 0.01);
20 | uniform float metallic : hint_range(0.0, 1.0, 0.01);
21 |
22 | uniform vec3 uv1_scale;
23 | uniform vec3 uv1_offset;
24 | uniform vec3 uv2_scale;
25 | uniform vec3 uv2_offset;
26 |
27 | void vertex() {
28 | // Vertex Color is sRGB: Enabled
29 | if (!OUTPUT_IS_SRGB) {
30 | COLOR.rgb = mix(
31 | pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)),
32 | COLOR.rgb * (1.0 / 12.92),
33 | lessThan(COLOR.rgb, vec3(0.04045)));
34 | }
35 |
36 | UV = UV * uv1_scale.xy + uv1_offset.xy;
37 | }
38 |
39 | float msdf_median(float r, float g, float b, float a) {
40 | return min(max(min(r, g), min(max(r, g), b)), a);
41 | }
42 |
43 | void fragment() {
44 | vec2 base_uv = UV;
45 |
46 | vec4 albedo_tex = texture(texture_albedo, base_uv);
47 |
48 | {
49 | // Albedo Texture MSDF: Enabled
50 | albedo_tex.rgb = mix(
51 | vec3(1.0 + 0.055) * pow(albedo_tex.rgb, vec3(1.0 / 2.4)) - vec3(0.055),
52 | vec3(12.92) * albedo_tex.rgb,
53 | lessThan(albedo_tex.rgb, vec3(0.0031308)));
E 54-> vec2 msdf_size = vec2(msdf_pixel_range) / vec2(albedo_texture_size));
55 | vec2 dest_size = vec2(1.0) / fwidth(base_uv);
56 |
57 | float px_size = max(0.5 * dot(msdf_size, dest_size), 1.0);
58 | float d = msdf_median(albedo_tex.r, albedo_tex.g, albedo_tex.b, albedo_tex.a) - 0.5;
59 | if (msdf_outline_size > 0.0) {
60 | float cr = clamp(msdf_outline_size, 0.0, msdf_pixel_range / 2.0) / msdf_pixel_range;
61 | albedo_tex.a = clamp((d + cr) * px_size, 0.0, 1.0);
62 | } else {
63 | albedo_tex.a = clamp(d * px_size + 0.5, 0.0, 1.0);
64 | }
65 | albedo_tex.rgb = vec3(1.0);
66 | }
67 |
68 | // Vertex Color Use as Albedo: Enabled
69 | albedo_tex *= COLOR;
70 |
71 | ALBEDO = albedo.rgb * albedo_tex.rgb;
72 |
73 | float metallic_tex = dot(texture(texture_metallic, base_uv), metallic_texture_channel);
74 | METALLIC = metallic_tex * metallic;
75 | SPECULAR = specular;
76 |
77 | vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
78 | float roughness_tex = dot(texture(texture_roughness, base_uv), roughness_texture_channel);
79 | ROUGHNESS = roughness_tex * roughness;
80 | ALPHA *= albedo.a * albedo_tex.a;
81 | ALPHA_SCISSOR_THRESHOLD = alpha_scissor_threshold;
82 | }
83 |

Steps to reproduce

  • Create a new project

  • Create a scene containing a Label3D node given some text

  • Import a font file with Multichannel Signed Distance Fields set to true

  • Assign this font to the Label3D node

OR

  • Enter project settings
  • Set gui/theme/default_font_multichannel_signed_distance_field to true
  • Save and restart

Minimal reproduction project (MRP)

minimalreproductionprojectlabel3d.zip

@clayjohn
Copy link
Member

Thank you for your report.

This has already been fixed by #100678!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants