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

Tonemapping affects other cameras in split screen #14389

Closed
paul-hansen opened this issue Jul 19, 2024 · 3 comments
Closed

Tonemapping affects other cameras in split screen #14389

paul-hansen opened this issue Jul 19, 2024 · 3 comments
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled

Comments

@paul-hansen
Copy link
Contributor

Bevy version

0.14.0
The release number or commit hash of the version you're using.

[Optional] Relevant system information

cargo 1.79.0 (ffa9cf99a 2024-06-03)
rustc 1.79.0 (129f3b996 2024-06-10)
Arch Linux (EndeavorOS), KDE, (tested both Wayland and X11)
Firefox 127.0.2 & Chrome 126.0.6478.126
Nvidia 3080 Driver version 555.58.02

AdapterInfo { name: "NVIDIA GeForce GTX 980, or similar", vendor: 4318, device: 0, device_type: Other, driver: "WebGL", driver_info: "2.0", backend: Gl }

What you did

Added tonemapping in a splitscreen game.

What went wrong

If it's not clear, break this out into:

  • what were you expecting?
    Tonemapping to look the same on each camera
  • what actually happened?
    The tonemapping looks more intense on other cameras, appears like it's multiplying the effect due to it not being constrained to the camera's viewport.

Additional information

You can replicate this with the official split_screen.rs example by setting the camera to have hdr: true and adding tonemapping: Tonemapping::AcesFitted to the camera bundle. AcesFitted is the most obvious since it's more extreme.
`

Example:
image

Interestingly if you add Msaa::Sample4 and then disable Camera::msaa_writeback it starts working correctly. Unfortunately that breaks the UI so that's not a good workaround #14388

@paul-hansen paul-hansen added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 19, 2024
@paul-hansen
Copy link
Contributor Author

paul-hansen commented Jul 19, 2024

Edit: This still has problems with UI on the top camera, background colors are being blended into the scene only on the top camera. So not a usable workaround either.

I was able to work around this with a lot of trial and error:

            camera: Camera {
                hdr: true,
                output_mode: CameraOutputMode::Write {
                    blend_state: Some(BlendState {
                        color: BlendComponent {
                            src_factor: BlendFactor::Dst,
                            dst_factor: BlendFactor::Zero,
                            operation: BlendOperation::Max,
                        },
                        alpha: default()
                    }),
                    clear_color: ClearColorConfig::None,
                },
                ..bevy_default.camera
            },

Setting the BlendOperation::Max, seems to be the key. Though when this is set, if any cameras viewports overlap they seem to combine their results in strange ways. I have a camera that I animate to be fullscreen again when one of the player's wins so it broke that, but I worked around that by resetting that camera's output_mode to default before animating it.
It doesn't feel like this is a proper solution though and was very hard to find so I'll leave this open for now. I think it's likely still drawing the tonemapping on the other cameras, just the max makes it only use the brightest color which happens to look like what I expect.

@paul-hansen
Copy link
Contributor Author

paul-hansen commented Jul 19, 2024

I patching bevy with this draft PR and it completely fixed this issue: #14287

@paul-hansen
Copy link
Contributor Author

Closing as completed in #14287

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

1 participant