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

Rotated text is rendered outside of its container #11241

Closed
rparrett opened this issue Jan 7, 2024 · 5 comments · Fixed by #11326
Closed

Rotated text is rendered outside of its container #11241

rparrett opened this issue Jan 7, 2024 · 5 comments · Fixed by #11326
Labels
A-Text Rendering and layout for characters A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior P-Regression Functionality that used to work but no longer does. Add a test for this!

Comments

@rparrett
Copy link
Contributor

rparrett commented Jan 7, 2024

Bevy version

main, since 0483b69

This would probably be fixed in a roundabout way by #9341

Relevant system information

AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
SystemInfo { os: "MacOS 13.6.2 ", kernel: "22.6.0", cpu: "", core_count: "10", memory: "64.0 GiB" }

scale_factor 1.0 and 2.0 were tested.

What you did

cargo run --example pbr

What went wrong

The "metallic" text on the right side should be aligned with the edge of the right column of spheres. But it is overlapping them.

I added background_color: Color::RED.into() in the screenshot below.

image

Additional information

It seems sort of like a coincidence that this worked before. I think that this https://github.com/ickshonpe/bevy/blob/99c43fabdfed9fe9fa161c2d4f3dfbdb8ea35a5b/crates/bevy_ui/src/render/mod.rs#L646 is the problem line, or close to it.

There may be other bits of rotated text in the examples that should be looked at.

@rparrett rparrett added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jan 7, 2024
@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets P-Regression Functionality that used to work but no longer does. Add a test for this! and removed S-Needs-Triage This issue needs to be labelled labels Jan 7, 2024
@MaxiStev
Copy link

Text scaling also broken after the commit 0483b69
before
bevy_11
after
bevy_12

@ickshonpe
Copy link
Contributor

ickshonpe commented Jan 13, 2024

This is easy to fix, I'm just going to sort it out now, but we need a better solution for text orientation than hacking around with the transforms.

@ickshonpe ickshonpe added the A-Text Rendering and layout for characters label Jan 13, 2024
@ickshonpe
Copy link
Contributor

metallic

@ickshonpe
Copy link
Contributor

scale

@ickshonpe
Copy link
Contributor

Text scaling also broken after the commit [0483b69]

Text scaling shouldn't really be used anyway as the glyphs textures will still be the original size was so the result will probably look really bad.

github-merge-queue bot pushed a commit that referenced this issue Jan 13, 2024
# Objective

UI node text is drawn in the wrong position after rotation or scaling.


![294723406-d031a3e6-a4f9-48b4-a66a-ee963100a8b9](https://github.com/bevyengine/bevy/assets/27962798/2755e2e3-6a03-4ee8-8676-bdcaa72ec678)

## Solution
In `extract_text_uinodes` to set the text's offset create a translation
matrix and multiply it by the UI node's transform.

Previously the offset was just added directly to the translation of the
Node's `GlobalTransform`, which meant no scaling or rotation would be
applied to the offset.

<img width="961" alt="296440025-537ec11c-1ea1-469c-8eec-2ad4ae012095"
src="https://github.com/bevyengine/bevy/assets/27962798/eae1a1d2-1369-47ad-8963-3862d03ec0bf">

<img width="961" alt="296440156-dd04029d-8112-4fa5-89a2-56d7acab66df"
src="https://github.com/bevyengine/bevy/assets/27962798/90b1b6db-13f4-4745-9f14-7c1661baad50">

Fixes #11241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Text Rendering and layout for characters A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior P-Regression Functionality that used to work but no longer does. Add a test for this!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants