-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Gizmos rendering behind 2D objects if their z value is above 0 #9308
Comments
Further on this. In my current game project. I use the ecs_tilemap crate to render multiple layers. Im using rapier physics crate for collisions, rigid bodies and the gizmos on the Collision component doesnt not show up. Since 0.11.0, the debug borders are rendered using gizmos. Since the tilemap is being rendered above a Z of 0 for the different layers. When I walk off my tilemap or disable it I see the debug borders. |
I've been playing around a bit more, diving into the API docs. Is this intended behavior? Using 2 cameras with different rendering layers. So my first camera I set to render on top, but make it render layer 0 (default render layer). commands.spawn((
Camera2dBundle {
camera_2d: Camera2d {
clear_color: ClearColorConfig::None,
..default()
},
camera: Camera {
order: 1,
..default()
},
..default()
},
RenderLayers::from_layers(&[0]),
));
commands.spawn((
Camera2dBundle {
camera: Camera {
order: 0,
..default()
},
..default()
},
RenderLayers::from_layers(&[1]),
)); Then I spawn in my Mesh, Sprite and Collider at RenderLayer 1 and the gizmos all appear on top of everything. commands.spawn((
SpriteBundle {
sprite: Sprite {
color: Color::rgb(0.25, 0.25, 0.75),
custom_size: Some(Vec2::new(50.0, 200.0)),
..default()
},
transform: Transform::from_translation(Vec3::new(0., 0., 100.)),
..default()
},
RenderLayers::layer(1),
));
let sprite_size = 150.0;
commands.spawn((
SpriteBundle {
texture: asset_server.load("Grass.png"),
transform: Transform::from_xyz(0., 0., 50.),
..default()
},
RigidBody::Fixed,
Collider::cuboid(sprite_size / 2., sprite_size / 2.),
Velocity::zero(),
RenderLayers::layer(1),
)); |
with The |
Awesome, thanks. |
I took a very cursory glance at the code, and didn't immediately identify the source of the error. But if it is due to orthographic projection, then the bug lies in I'm not sure this is true, but when computing the depth, it should account for orthographic cameras when multiplying by the view projection. The function named But again I'm not 100% this is the source of the bug, I might be sending you on a wild goose chase. |
Its better than not knowing where to start. I'll look into those functions |
Make sure to enable the |
Maybe it has already gotten fixed |
maybe #9129 |
yeah. Looks like it. Closing |
Bevy version
0.11.0
[Optional] Relevant system information
What you did
Setup a basic 2D Camera scene.
Draw some Gizmos to the screen.
Draw a rectangle to the screen with a Z value above 0.
What went wrong
The Gizmos appears behind the rectangle.
Is this supposed to happen or is there a way to make sure the gizmos are always on top.
Or at least to choose at which z value to render
Additional information
I tried setting the depth_bias
The text was updated successfully, but these errors were encountered: