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

[Merged by Bors] - Update post_processing example to not render UI with first pass camera #6469

Closed
wants to merge 2 commits into from

Conversation

darthdeus
Copy link
Contributor

@darthdeus darthdeus commented Nov 4, 2022

Objective

Make sure the post processing example won't render UI twice.

Solution

Disable UI on the first pass camera with UiCameraConfig

@@ -42,11 +42,43 @@ fn setup(
) {
let window = windows.primary_mut();
let size = Extent3d {
width: window.physical_width(),
height: window.physical_height(),
width: window.width() as u32,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will actually render this at a lower resolution when the scale factor is above 1, which isn't what we want generally. Scenes should still render at the native resolution. It is ui that needs to be scaled up.

..default()
};

commands
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of this is example is to minimally illustrate a post processing effect. This UI serves no purpose other than to prove that a bug has been resolved. It introduces additional complexity that distracts from the purpose, so I think it should be removed.

@@ -147,6 +179,7 @@ fn setup(
..Camera2dBundle::default()
},
post_processing_pass_layer,
UiCameraConfig { show_ui: false },
Copy link
Member

@cart cart Nov 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal take is that this is on the wrong camera. I would assert that UI should be added in the "final" pass without post processing effects applied (in the majority of cases). Moving this to the other camera also resolves the "wrong ui scale factor" problem, as it will inherit the window's scale factor (rather than assuming a scale factor of 1.0 for the Image rendertarget)

Copy link
Contributor Author

@darthdeus darthdeus Nov 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But moving this to the other camera only resolves this in the case where the user doesn't want the post processing applied to the UI. What if the user wants the UI to have post processing applied? Seems that if rendering is done at the actual physical size with window.physical_size() the UI layout system won't take it into consideration and positions/sizes things based on the logical size instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a much less common scenario, so I don't think we should cover it here, especially given the downsides I've already covered. That scenario will be covered by any of the following:

There is also the approach you employed here as a short term solution, but I don't want to encourage that pattern generally as it encourages the "wrong" outcomes (such as rendering at a resolution lower than you should).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have plans for a higher level "post processing stack" which will likely subsume all of these scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay makes sense, closing the PR then 👍

@darthdeus darthdeus closed this Nov 5, 2022
@rparrett
Copy link
Contributor

rparrett commented Nov 5, 2022

I have seen at least one other person get hit by the double-UI thing while trying to build off of this example.

I think a PR to disable UI for the other camera would be welcome.

@darthdeus darthdeus reopened this Nov 5, 2022
@darthdeus
Copy link
Contributor Author

I have seen at least one other person get hit by the double-UI thing while trying to build off of this example.

I think a PR to disable UI for the other camera would be welcome.

Not sure if it makes sense to make a new PR for that, but just for simplicity I pushed the changes here since the original changes don't make sense anymore. The only change now is what you said, the disabling of the UI being rendered by the first camera.

@rparrett
Copy link
Contributor

rparrett commented Nov 5, 2022

Just need to update the PR title and description if we're reusing this PR.

@darthdeus darthdeus changed the title Fix post_processing example rendering UI twice + scaling incorrectly Update post_processing example to not render UI with first pass camera Nov 5, 2022
@darthdeus
Copy link
Contributor Author

Okay PR title and description updated.

@coreh
Copy link
Contributor

coreh commented Nov 5, 2022

Is it possible to make it so that UI rendering is only enabled by default for when there's a single camera? When multiple cameras are added, it's disabled by default and you need to add UiCameraConfig { show_ui: true } to one of them? Also if there are UI elements to render and not a single UI-enabled camera, you get a warning? That would perhaps be less surprising, and people wouldn't stumble on it then.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples labels Nov 7, 2022
@mockersf mockersf added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Nov 7, 2022
@cart
Copy link
Member

cart commented Nov 14, 2022

bors r+

bors bot pushed a commit that referenced this pull request Nov 14, 2022
#6469)

# Objective

Make sure the post processing example won't render UI twice.

## Solution

Disable UI on the first pass camera with `UiCameraConfig`
@bors bors bot changed the title Update post_processing example to not render UI with first pass camera [Merged by Bors] - Update post_processing example to not render UI with first pass camera Nov 14, 2022
@bors bors bot closed this Nov 14, 2022
@darthdeus darthdeus deleted the fix-pp-ui-scaling branch November 15, 2022 01:27
taiyoungjang pushed a commit to taiyoungjang/bevy that referenced this pull request Dec 15, 2022
bevyengine#6469)

# Objective

Make sure the post processing example won't render UI twice.

## Solution

Disable UI on the first pass camera with `UiCameraConfig`
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
bevyengine#6469)

# Objective

Make sure the post processing example won't render UI twice.

## Solution

Disable UI on the first pass camera with `UiCameraConfig`
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
bevyengine#6469)

# Objective

Make sure the post processing example won't render UI twice.

## Solution

Disable UI on the first pass camera with `UiCameraConfig`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants