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 Z Offset for Label3D and Sprite3D Nodes #4468

Open
stryker313 opened this issue Apr 29, 2022 · 4 comments
Open

Add Z Offset for Label3D and Sprite3D Nodes #4468

stryker313 opened this issue Apr 29, 2022 · 4 comments

Comments

@stryker313
Copy link

stryker313 commented Apr 29, 2022

Describe the project you are working on

A game that uses sprite3ds and label3ds to create world icons

Describe the problem or limitation you are having in your project

With the introduction of Label3D nodes, you can now create text, and place it in the world quite effortlessly.
The original way to do this, was to use a viewport assigned to a sprite3D, which, for those who are unfamiliar, is very cumbersome. Having to adjust the resolution, scale, constantly reapply the viewport texture etc. etc.

Label3D solved this problem.

However, there is one glaring issue.

Text is often not left by itself.

Desktop Screenshot 2022 04 28 - 13 36 06 72

Normally, you want to apply some sort of border, texture, something to make the text look neat.
However, when you put a Sprite3D and Label3D on top of each other, there can be undesirable effects.

Desktop Screenshot 2022 04 29 - 15 14 58 65

Now, there are various ways to resolve this, however, none of them are good solutions.
Option 1. Move the label in front of the sprite
Option 2. Use viewport with sprite3d
Option 3. Use combination of disable depth test with alpha cut set to discard
Option 4. Use material with grow property

Option 1. Although this will work for certain angles, if you wish to use billboard, this will not work, as you would need the center of origin to be the same

Option 2. Again, Label3D was made to avoid this issue

Option 3. This is actually a decent solution at the moment, however, this results in the texture being visible at all times, requiring use of visibility range which is a bit hacky
Desktop Screenshot 2022 04 29 - 15 16 32 59

Option 4. I haven't experimented with this one enough, but there may be some potential here. However, you will not be able to use animated sprites without a bit more "hacking"
Desktop Screenshot 2022 04 29 - 15 17 14 70

Overall, the solutions are very niche, and come with their sets of ups and downs.

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

A z offset would allow you to have the text render in front of a sprite very easily, without all the hacky workaround.

Additionally, a z offset would allow for more intricate 3d world UI, as you can now design transparent textures modularly, and layer them with Sprite3D nodes.

The closest thing to a z offset at the moment would be the material "grow" property, which shows it should somewhat be possible?

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

Simply, there will be an additional option for Z offset, and this will move the Sprite/text on the z axis.

Desktop Screenshot 2022 04 28 - 13 36 41 95

An easy visualization for how this can work can be seen with the "grow" modifier on a material3d, where growing the texture
slides the texture across the z axis.
Desktop Screenshot 2022 04 29 - 15 17 14 70

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

This can be worked around, however, it would negate the work that was put into making Label3D useful to begin with. If you were to use a texture with text in a billboard scenario, you would have to go back to using a viewport with sprite3d.

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

Core. Also, there recently was (#60595), so why not add z axis?

@Calinou
Copy link
Member

Calinou commented Apr 29, 2022

Related to #3986.

@stryker313
Copy link
Author

@bruvzg

@bruvzg
Copy link
Member

bruvzg commented Apr 30, 2022

We can expose material render priority for both to allow sorting sprites and labels manually, this should solve the issue.

@bruvzg
Copy link
Member

bruvzg commented Apr 30, 2022

render priority access PR for the sprites and labels - godotengine/godot#60650, it's a pretty limited approach, but is using only existing engine features.

While it should be sufficient for most cases, a proper implementation #3986 (Sorting Groups/Layers) would be highly appreciated.

@akien-mga akien-mga added this to the 4.0 milestone Apr 30, 2022
@aaronfranke aaronfranke modified the milestones: 4.0, 4.x Feb 24, 2023
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

5 participants