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

multiple_windows does not render in secondary window #4378

Closed
aevyrie opened this issue Mar 31, 2022 · 5 comments
Closed

multiple_windows does not render in secondary window #4378

aevyrie opened this issue Mar 31, 2022 · 5 comments
Labels
A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior C-Examples An addition or correction to our examples P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@aevyrie
Copy link
Member

aevyrie commented Mar 31, 2022

Bevy version

main

Operating system & version

Win11

What you did

cargo run --example multiple_windows

What you expected to happen

The gltf should render in both windows

What actually happened

The model only shows in one window, but not consistently the same one

Additional information

image
image

@aevyrie aevyrie added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Mar 31, 2022
@DJMcNab DJMcNab added A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Triage This issue needs to be labelled labels Mar 31, 2022
@alice-i-cecile alice-i-cecile added the A-Windowing Platform-agnostic interface layer to run your app in label Mar 31, 2022
@DJMcNab
Copy link
Member

DJMcNab commented Mar 31, 2022

I can reproduce. Interestingly, it seems to arbitrarily select one camera to work; I imagine that there's some hashmap somewhere causing this behaviour.

I'm assuming it's a camera issue, since the clear pass is running successfully.

@aevyrie
Copy link
Member Author

aevyrie commented Mar 31, 2022

Yeah, I just noticed the same thing and updated the ticket. 👍

@mockersf
Copy link
Member

the randomness probably comes from

pub fn set_active_camera<T: Component>(
mut active_camera: ResMut<ActiveCamera<T>>,
cameras: Query<Entity, With<T>>,
) {
if active_camera.get().is_some() {
return;
}
if let Some(camera) = cameras.iter().next() {
active_camera.camera = Some(camera);
}
}

@cart
Copy link
Member

cart commented Mar 31, 2022

Yeah we changed from rendering all cameras of a given type to just the active one (which is why this used to work).
Historically we did these:

  1. Prior to this pr: created a brand new camera type and manually updated the render graph. Each type (the default and the secondary camera) had its own active camera, which we selected.
  2. Old version of this pr: rendered every camera with the same type (indiscriminately). Not the direction we should be headed in imo.
  3. Merged version of this pr: render active cameras of a given type.

The missing piece here is choosing the "right" way to drive rendering. This is the "camera driven" vs "render target driven" discussion started in #4191.

This is next on my todo list, but I've been focused on merging other peoples' work for 0.7 for awhile now. I'm pretty close to being out of that hole though.

I think we "need" active cameras with the current paradigm (and RenderTarget driven rendering). There are flavors of camera-driven where we don't (see #4191 for more info), but our current impl isn't that.

If we can't merge a full solution before 0.7, I think the move is to re-add the "second window camera type / render graph" pattern to this example, but I really want higher level render targets that "just work" asap.

@cart
Copy link
Member

cart commented Mar 31, 2022

Also sorry for the example regression 😄

@bors bors bot closed this as completed in 0ed08d6 Apr 1, 2022
aevyrie pushed a commit to aevyrie/bevy that referenced this issue Jun 7, 2022
The example was broken in bevyengine#3635 when the `ActiveCamera` logic was introduced, after which there could only be one active `Camera3d` globally.
Ideally there could be one `Camera3d` per render target, not globally, but that isn't the case yet.

To fix the example, we need to
- don't use `Camera3d` twice, add a new `SecondWindowCamera3d` marker
- add the `CameraTypePlugin::<SecondWindowCamera3d>`
- extract the correct `RenderPhase`s
- add a 3d pass driver node for the secondary camera

Fixes bevyengine#4378

Co-authored-by: Jakob Hellermann <[email protected]>
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
The example was broken in bevyengine#3635 when the `ActiveCamera` logic was introduced, after which there could only be one active `Camera3d` globally.
Ideally there could be one `Camera3d` per render target, not globally, but that isn't the case yet.

To fix the example, we need to
- don't use `Camera3d` twice, add a new `SecondWindowCamera3d` marker
- add the `CameraTypePlugin::<SecondWindowCamera3d>`
- extract the correct `RenderPhase`s
- add a 3d pass driver node for the secondary camera

Fixes bevyengine#4378

Co-authored-by: Jakob Hellermann <[email protected]>
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 A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior C-Examples An addition or correction to our examples P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants