bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.13k stars 3.56k forks source link

Add support for text widgets in 3d #5598

Open Weibye opened 2 years ago

Weibye commented 2 years ago

What problem does this solve or what need does it fill?

User should be able to place text widgets in 3d space and have it be rendered by the 3d camera

What solution would you like?

What alternative(s) have you considered?

Additional context

@HackerFoo Implemented a workaround for his application Noumenal which involved using Text2dBundles, adding a 2d camera and matching the projection to the 3d camera. This adds another pass which can be slow on mobile.

alice-i-cecile commented 1 year ago

This was hacked around by https://github.com/bevyengine/bevy/pull/6644. We should a) look at how this was done for inspiration, and b) clean up that example once this is added.

ruifengx commented 1 year ago

This was hacked around by #6644. We should a) look at how this was done for inspiration, and b) clean up that example once this is added.

I am also interested in this, and I just had a look on the linked PR. The text labels are added as UI elements, and their positions are adjusted manually using a system. I am okay with the procedure involved, since the boilerplates are O(1) with respect to the number of text labels. I believe it could even be extended to read the camera settings and scale the texts so that elements farther from the camera look smaller. However, I can think of one problem of this approach: the UI elements are always rendered on top of the world, meaning it is impossible to have part of the text hidden behind an object. I think we still need a full-fledged world-space UI as in #5476.

nixpulvis commented 2 months ago

I've found https://github.com/kulkalkul/bevy_mod_billboard solves 75% of my use cases. Though as I want more control over the text, I'm finding myself wishing I could reach for a Bevy 3D text primitive.

With #7426 and #5476 in mind, what would the advantage of using one method over the other?

I'm also curious if 3D text billboarding something bevy might want to mainline as well?

alice-i-cecile commented 2 months ago

Yep, billboarding of all sorts, including text, is something that we would like to include in Bevy itself.

In my mind, there's a performance-centric distinction between "simple 2d/3d text" and "worldspace UI". The former simply creates and renders meshes in the shape of text, while the latter supports arbitrary picking, layout, widgets and so on.

Speed is important for many simple cases, so simply telling users to generate worldspace UI is likely to be insufficient for e.g. Diablo-style floating numbers.