Skip to content

render::view::RenderLayers does not affect SpriteBundle #5089

@lostinnowhere314

Description

@lostinnowhere314

Bevy version

0.7.0

What you did and what went wrong

I was trying to adapt the render_to_texture.rs example to a 2-d example, and the error that occured is precisely the one that the example attributes to trying to write to and use the same texture in the same draw call. I was using a SpriteBundle to render the texture being drawn to, particularly.

Example

Here's a simple example (derived from the sprite.rs example) that illustrates this:

use bevy::prelude::*;
use bevy::render::view::RenderLayers;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .run();
}

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn_bundle(OrthographicCameraBundle::new_2d())
		.insert(RenderLayers::layer(0));
    commands.spawn_bundle(SpriteBundle {
        texture: asset_server.load("branding/icon.png"),
        ..default()
    })
		.insert(RenderLayers::layer(1));
}

The sprite should not render, according to the RenderLayer documentation; however, the result is that the sprite renders anyways.

Relevant system information

Windows 10, Rust version 1.61.0

AdapterInfo { name: "Intel(R)
UHD Graphics", vendor: 32902, device: 39745, device_type: IntegratedGpu, backend: Vulkan }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions