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

Add a Label3D node to display text in a 3D world using SDF font rendering #3219

Closed
Calinou opened this issue Aug 29, 2021 · 5 comments
Closed

Comments

@Calinou
Copy link
Member

Calinou commented Aug 29, 2021

Note: This proposal was discussed with reduz and is probably fine to implement.

Related to godotengine/godot#31352.

Describe the project you are working on

The Godot editor 🙂

Describe the problem or limitation you are having in your project

Drawing text in a 3D world in Godot is already possible, but can be cumbersome, especially for beginners. Depending on your needs, there are two ways to go about it, each with their own limitations:

  • Project a Label node using Camera.unproject_position(). This is what is done in the 3D waypoints demo.
    • Does not handle projection on a 3D surface or partial occlusion of text. It's possible to use a raycast to occlude the text in an "all or nothing" fashion, but nothing more.
  • Display a Label node inside a Viewport that renders to a texture and assign the resulting ViewportTexture to a Sprite3D or MeshInstance node. This is what is done in the GUI in 3D demo.
    • Does not always look good due to the limited resolution of the viewport and variable viewing distances.
    • Has additional rendering cost due to the housekeeping required for the Viewport.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a Label3D node to display text in a 3D world using SDF font rendering. This allows fulfilling both needs above with a single node.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Now that multi-channel SDF font rendering is merged, we can implement similar functionality in 3D by using the same principle in a dedicated material shader option. The same font resources can likely be used as well.

Billboarding should be optional (and enabled by default). It can be disabled for things such as Minecraft-style sign writing.

If this enhancement will not be used often, can it be worked around with a few lines of script?

This can be done using a custom shader, but it's still quite a lot of work to do manually and expose in a convenient way. Nonetheless, it's still possible to develop this as an add-on.

Is there a reason why this should be core and not an add-on in the asset library?

Displaying text in a 3D world is often done throughout the development of a 3D game. Even if it never ends up being used during actual gameplay, text in the 3D world is sometimes used during level blockouts as well to denote landmarks in the blockout.

@Zireael07
Copy link

Note that many games use text in 3d world for waypoints or player tags.

@lentsius-bark
Copy link

Another way of having text in 3D is creating an AnimatedSprite3D and setting frames according to the character you want to use. However this is super tedious as it needs loads of custom logic for anything beyond most basic and a spritesheet with a font.

Either way I am supremely excited for having a native Label3D. Diegetic UIs will be all that much easier from Godot 4 onwards thanks to these changes.

@eon-s
Copy link

eon-s commented Aug 29, 2021

Label3D is better than nothing but sounds very limited, games nowadays use a lot more complex UI-like elements in 3D worlds so a full Control3D/Container3D may be better than just a label, RTL3D could make more sense.

@Janders1800
Copy link

Label3D is better than nothing but sounds very limited, games nowadays use a lot more complex UI-like elements in 3D worlds so a full Control3D/Container3D may be better than just a label, RTL3D could make more sense.

You can use the already existing viewports for that.

I agree a simpler more performant label3d would be great, and I think it is an enough common case to have its own node.

@akien-mga
Copy link
Member

Implemented by godotengine/godot#60386.

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

6 participants