Skip to content

Multiples camera with RenderLayers doesn't work with Msaa::Off (solved ?) #15467

Closed
@mirsella

Description

@mirsella

Bevy version

0.14.2

[Optional] Relevant system information

archlinux wayland kde
AdapterInfo { name: "AMD Radeon RX 7800 XT (RADV NAVI32)", vendor: 4098, device: 29822, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 24.2.3-arch1.1", backend: Vulkan }

What you did

i have a game with a bevy ui grid, and i wanted to draw gizmo on it. It was quite hard as the documentation is hard to find.
Based off #13027 i tried the example given with 2 cameras and render layer, which works with little modification, but not on my game, the gizmo are drawing but not the ui.
after hours of pain trying different things, i found it was when i had app.insert_resource(Msaa::Off) that the ui didn't show.

use bevy::{
    color::palettes::css::{MIDNIGHT_BLUE, RED, YELLOW},
    prelude::*,
    render::view::RenderLayers,
};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .insert_gizmo_config(
            DefaultGizmoConfigGroup,
            GizmoConfig {
                render_layers: RenderLayers::layer(1),
                ..default()
            },
        )
        // .insert_resource(Msaa::Off)
        .add_systems(Startup, setup)
        .add_systems(Update, gizmos)
        .run();
}

fn setup(mut commands: Commands) {
    // "Bottom" camera
    let camera0 = commands.spawn(Camera2dBundle::default()).id();

    // "Top" camera
    let mut camera2 = Camera2dBundle::default();
    camera2.camera.order = 1;
    commands.spawn((camera2, RenderLayers::layer(1)));

    commands.spawn((
        ImageBundle {
            style: Style {
                width: Val::Percent(100.0),
                height: Val::Percent(100.0),
                ..default()
            },
            image: UiImage::solid_color(MIDNIGHT_BLUE.into()),
            ..default()
        },
        // use the default first camera for ui
        TargetCamera(camera0),
    ));
}

fn gizmos(mut gizmos: Gizmos) {
    gizmos.line_2d(Vec2::new(-25.0, 25.0), Vec2::new(25.0, 25.0), RED);
    gizmos.line_2d(Vec2::new(0.0, 0.0), Vec2::new(0.0, 50.0), YELLOW);
}

What went wrong

The gizmos are drawn, but the ui is invisible, not shown.
You can test this by un commenting the insert msaa off line in main.

thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions