bevyengine / bevyengine/bevy

Post Processing example bugs (double rendering of UI + wrong handling of system level UI scaling)

Open
#6,467 2 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Bug C-Examples
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

1bd3d8576941d09fc43fef901e1bbbf45b24c544

## What you did

Run the post processing example with extra UI, with `cargo run --example post_processing`

```rust
// add this anywhere in the `setup` function
commands
.spawn(NodeBundle {
style: Style {
justify_content: JustifyContent::FlexEnd,
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
..default()
},
background_color: BackgroundColor(Color::NONE),
..default()
})
.with_children(|commands| {
commands
.spawn(NodeBundle {
background_color: BackgroundColor(Color::MAROON),
style: Style {
size: Size::new(Val::Px(100.0), Val::Auto),
..default()
},
..default()
})
.with_children(|commands| {
commands.spawn(NodeBundle {
background_color: BackgroundColor(Color::PINK),
style: Style {
size: Size::new(Val::Percent(100.0), Val::Percent(50.0)),
..default()
},
..default()
});
});
});
```

## What went wrong

Two problems:

- The UI is rendered twice (once with each camera)
- The UI is positioned incorrectly when system scaling is enabled, in my case it's set to 1.13

## Additional information

The problem is using `window.physical_width()` instead of `window.width()` (or at least dividing by `window.scale_factor()`)

![image](https://user-images.githubusercontent.com/123374/200077844-1a311788-d012-4484-bb06-f13418526aca.png)

edit: I'll submit a PR to fix this in a little bit

Contributor guide

Open the contributing guide

Research direction

Start by running the post_processing example with `cargo run --example post_processing`, including the extra UI shown in the report, and inspect its setup and camera handling. Done means the UI renders only once and its position remains correct when system scaling is enabled, including the reported 1.13 scale factor.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.