bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.23k stars 3.57k forks source link

Intermittent Rendering bug #11994

Closed franklinblanco closed 8 months ago

franklinblanco commented 8 months ago

Bevy version

0.12

Relevant system information

cargo 1.77.0-nightly (1ae631085 2024-01-17)

AdapterInfo { name: "Apple M1 Pro", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }

What you did

Nothing specific. This bug just happens randomly, approximately 1/12-1/20 times I start a bevy app.

What went wrong

When starting the app, the camera seems to be culling meshes near the edges of the screen. I can't seem to fix this issue by resizing the window or doing anything really, I just have to restart the App.

https://github.com/bevyengine/bevy/assets/72827992/ef3b6de8-e0d9-4ba9-94b6-809f9ccbcedb

Additional information

Camera setup:

for camera in cameras_query.iter() {
        let image = images.get_mut(&game_assets.skybox).unwrap();
        if image.texture_descriptor.array_layer_count() == 1 {
            image.reinterpret_stacked_2d_as_array(
                image.texture_descriptor.size.height / image.texture_descriptor.size.width,
            );
            image.texture_view_descriptor = Some(TextureViewDescriptor {
                dimension: Some(TextureViewDimension::Cube),
                ..default()
            });
        }
        commands
        .entity(camera)
        .insert(PerspectiveProjection {
            fov: 60.0_f32.to_radians(),
            near: 0.001,
            ..Default::default()
        })
        .insert(Skybox(game_assets.skybox.clone()));
    }
rparrett commented 8 months ago

I would guess that this is due to your camera now having both of these components:

Projection (You're inserting this) PerspectiveProjection (Part of Camera3dBundle, and still holding the default projection)

Could you try modifying your code to instead insert

Projection::from(PerspectiveProjection {
    fov: 60.0_f32.to_radians(),
    near: 0.001,
    ..Default::default()
})

Bevy's handling of these components is a bit awkward.

Related issue: #11807

franklinblanco commented 8 months ago

@rparrett Thank you for the reply. Currently testing to see if it happens again. If I don't see it in a couple of days I'll let you know and close this. Thank you!

franklinblanco commented 8 months ago

I think this is enough time. This fixed the issue for me. If I encounter it again I'll reopen. Thank you very much!