Skip to content

Fix atmosphere not allowing multiple cameras#23113

Open
stevesloan wants to merge 4 commits into
bevyengine:mainfrom
stevesloan:fix-multicam-atmosphere
Open

Fix atmosphere not allowing multiple cameras#23113
stevesloan wants to merge 4 commits into
bevyengine:mainfrom
stevesloan:fix-multicam-atmosphere

Conversation

@stevesloan
Copy link
Copy Markdown

Objective

Allow multiple cameras to render an atmosphere enabling split screen and VR apps to use the feature

Solution

Use iter().next() instead of single() for when multiple Atmosphere entities exist

Testing

Tested this by adding a second camera to the atmosphere example.
Tested it in VR with the bevy_oxr crate

@github-actions
Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy A-Rendering Drawing game state to the screen O-XR Specific to virtual and augmented reality platforms labels Feb 22, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Feb 22, 2026
@alice-i-cecile alice-i-cecile added D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed D-Trivial Nice and easy! A great choice to get started with Bevy labels Feb 22, 2026
@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Feb 22, 2026
@@ -797,7 +797,7 @@ pub(crate) fn write_atmosphere_buffer(
atmosphere_entity: Query<(&GpuAtmosphere, &GpuAtmosphereSettings), With<Camera3d>>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could probably make this a bit more idiomatic / nicer by swapping the Query here to Populated.

mut atmosphere_buffer: ResMut<AtmosphereBuffer>,
) {
let Ok((atmosphere, settings)) = atmosphere_entity.single() else {
let Some((atmosphere, settings)) = atmosphere_entity.iter().next() else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This approach seems a bit weird: we're assuming that every camera uses the same atmosphere settings as the first camera that happens to match the camera?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

True, the AtmosphereBuffer is a resource, i am working on a commit to change it to a component

@stevesloan
Copy link
Copy Markdown
Author

AtmosphereBuffer was changed from a Resource to a Component, and the pub function init_atmosphere_buffer was removed. These could be breaking changes

@stevesloan
Copy link
Copy Markdown
Author

Can be tested with this modified example

atmosphereMulticam.rs.txt

@alice-i-cecile alice-i-cecile added the M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Feb 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

@alice-i-cecile
Copy link
Copy Markdown
Member

AtmosphereBuffer was changed from a Resource to a Component, and the pub function init_atmosphere_buffer was removed. These could be breaking changes

This makes sense to me, but it'll need a migration guide. The bot should be by with directions momentarily :)

@stevesloan stevesloan force-pushed the fix-multicam-atmosphere branch from 20cd993 to ec07834 Compare April 13, 2026 18:40
…here

# Conflicts:
#	crates/bevy_pbr/src/render/mesh_view_bindings.rs
@cart cart closed this May 5, 2026
@github-project-automation github-project-automation Bot moved this from Needs SME Triage to Done in Rendering May 5, 2026
@cart cart reopened this May 5, 2026
@github-project-automation github-project-automation Bot moved this from Done to Needs SME Triage in Rendering May 5, 2026
stevesloan added 2 commits May 5, 2026 15:18
…here

# Conflicts:
#	crates/bevy_pbr/src/render/mesh_view_bindings.rs
@cart cart added this to the 0.20 milestone May 5, 2026
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-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide O-XR Specific to virtual and augmented reality platforms S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants