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

The OrthographicProjection has it's default values overriden in Camera2dBundle's default implementation, causing counter-intuitive problems #12267

Closed
Gaspard-- opened this issue Mar 2, 2024 · 2 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@Gaspard--
Copy link

Hello!

I don't know if this should be a feature request or a bug.

Since this is about unexpected behavior, I feel like a bug fits better.

Bevy version

0.13

What you did

Warning in advance: still a beginner at rust, so I might be using an anti-pattern somewhere.

I was messing around with different values to initialize the Camera2dBundle with, and noticed my rendering seems to disappear sometimes.
After looking at the source code, I found these lines:

fn default() -> Self {
let projection = OrthographicProjection {
far: 1000.,
near: -1000.,
..Default::default()
};

This means, that when initializing the camera on your side using a camera 2d bundle, if you want a scale, you must be careful to also specify znear / zfar.

        Camera2dBundle{
            projection: OrthographicProjection {
                scaling_mode: ScalingMode::FixedVertical(2.0),
                // not specfying these 2 fields can break rendering
                far: 1000.0,
                near: -1000.0,
                ..OrthographicProjection::default()
            },
            ..default()
        }

What went wrong

When not specifying znear / zfar, all sprites and text stop appearing.

I think it would be better if the defaults of OrthographicProjection work out of the box, but I don't know the internals of bevy enough to know if this is reasonnable. A warning in the docs would also may be a solution.

Additional information

I saw #239, but I don't think it's related since any scale value breaks the rendering.

@Gaspard-- Gaspard-- added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Mar 2, 2024
@TrialDragon TrialDragon added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed S-Needs-Triage This issue needs to be labelled labels Mar 2, 2024
@the-az-dev
Copy link

the-az-dev commented Jul 6, 2024

I wrote about this in #239 so, I will paste link to this comment https://github.com/bevyengine/bevy/issues/239#issuecomment-2211712442

@Azorlogh
Copy link
Contributor

Azorlogh commented Sep 9, 2024

I think this can be closed this too 🙂 #15073
@alice-i-cecile

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 C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants