-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Implement TextMesh. #60507
Implement TextMesh. #60507
Conversation
Can you send it through the lod system? Aka. The Meshoptimizer system? I can look into this later. It's not so good for the mesh to be recreated every frame, but it's good for the first implementation. If you can't generate the uvs manually, you could use xatlas. |
2936982
to
d3a152a
Compare
I gave it a try 🙂 Testing project: test_textmesh.zip Some comments:
We should also look to compile some use cases for TextMesh (and where Label3D isn't a good fit). Label3D is a powerful node already, and we should be careful not to have feature creep in this aspect of the engine. |
19b3014
to
d8a8734
Compare
Can this be ported to 3.x? |
56baf7f
to
abeef06
Compare
Not sure if it's necessary, with the reasonable curve step it should be good as is.
It's probably a bit of overkill to use full unwrap, something simple and applicable to any text without changing the texture probably is a more useful as a default and should cover most cases. So currently it's using a map like this to have a possibility to texture front back and sides of text independently (front and back and for the full text, and sides to loop each contour): But I guess adding a separate option to do unwrap on any mesh would be useful. |
Probably not, at least not without backporting some other stuff to the 3.x, and it won't have any of the TextServer features available. |
I tested the latest revision of this PR and can confirm the timer in the testing project now performs much better (even when it shows 4 decimals). The rotating text animation remains smooth and I still get 300+ FPS. In practice, I'd probably limit the timer in the example to 2 decimals, but this should now be suitable for real-time use. |
You are amazing! I just spend at least week on painstakingly trying to get dynamic 3D text mesh (mesh created in Blender letter by letter) in one of my projects in Godot 3 to write 4 words. It's super tedious and limited process and I can't imagine doing this ever again and was about to write a feature request proposal of exactly this! Question: Will I be able to generate CollisionShape Siblings from this like I can with MeshInstances (or alternatively make this TextMesh the Mesh of a MeshInstance so I can generate the CollisionShape Siblings)? |
I have not tested collisions, but it's a derivative of generic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature looks great, and the code seems fine from a quick look. Might warrant a rebase to make sure it still builds after the HashMap rewrite.
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text"), "set_text", "get_text"); | ||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_font", "get_font"); | ||
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_size", PROPERTY_HINT_RANGE, "1,127,1"), "set_font_size", "get_font_size"); | ||
ADD_PROPERTY(PropertyInfo(Variant::INT, "horizontal_alignment", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), "set_horizontal_alignment", "get_horizontal_alignment"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the documentation says only left, center, and right are supported, maybe we should remove the "Fill" option here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed pixel_size
not cleaning cache, added width
for Fill
alignment and updated docs for this and Label3D
(both support Fill
alignment).
Apply simulated slant and embolden to the TextServer `gont_get_glyph_contours` results.
Thanks! |
Follow up to the #60386
Implement
TextMesh
resource.Implements mesh generation from the shaped text contours. Works only with the OpenType compliant dynamic fonts (without contour self-intersections, so some fonts converted by services like Google Font might fail). Will not work with bitmap fonts (regardless of font container format), e.g., color emoji fonts.
TODO:
Test project:
test_project.zip