diff --git a/crates/bevy_render/src/camera/projection.rs b/crates/bevy_render/src/camera/projection.rs index 2da70c253c..3e35afdfcc 100644 --- a/crates/bevy_render/src/camera/projection.rs +++ b/crates/bevy_render/src/camera/projection.rs @@ -55,7 +55,7 @@ pub struct OrthographicProjection { impl CameraProjection for OrthographicProjection { fn get_view_matrix(&self) -> Mat4 { - let projection = Mat4::orthographic_rh_gl( + let projection = Mat4::orthographic_rh( self.left, self.right, self.bottom, @@ -92,8 +92,8 @@ impl Default for OrthographicProjection { right: 0.0, bottom: 0.0, top: 0.0, - near: 0.0, - far: 1.0, + near: -1.0, + far: 0.1, window_origin: WindowOrigin::Center, } } diff --git a/crates/bevy_sprite/src/render/sprite.vert b/crates/bevy_sprite/src/render/sprite.vert index e77712518b..767fefd810 100644 --- a/crates/bevy_sprite/src/render/sprite.vert +++ b/crates/bevy_sprite/src/render/sprite.vert @@ -19,6 +19,6 @@ layout(set = 1, binding = 0) uniform Quad { void main() { v_Uv = Vertex_Uv; vec3 position = Vertex_Position * vec3(Quad_Size, 0.0); - position = position + vec3(Quad_Position, -Quad_ZIndex); + position = position + vec3(Quad_Position, Quad_ZIndex); gl_Position = ViewProj * vec4(position, 1.0); } \ No newline at end of file diff --git a/crates/bevy_ui/src/render/ui.vert b/crates/bevy_ui/src/render/ui.vert index c2c269cbb6..5112b23c07 100644 --- a/crates/bevy_ui/src/render/ui.vert +++ b/crates/bevy_ui/src/render/ui.vert @@ -19,6 +19,6 @@ layout(set = 1, binding = 0) uniform Quad { void main() { v_Uv = Vertex_Uv; vec3 position = Vertex_Position * vec3(Quad_Size, 0.0); - position = position + vec3(Quad_Position, -Quad_ZIndex); + position = position + vec3(Quad_Position, Quad_ZIndex); gl_Position = ViewProj * vec4(position, 1.0); } \ No newline at end of file diff --git a/crates/bevy_ui/src/ui_update_system.rs b/crates/bevy_ui/src/ui_update_system.rs index 46532a25ed..5866534b7a 100644 --- a/crates/bevy_ui/src/ui_update_system.rs +++ b/crates/bevy_ui/src/ui_update_system.rs @@ -20,7 +20,7 @@ pub fn ui_update_system() -> Box { let mut window_quad = Quad { size: Vec2::new(window.width as f32, window.height as f32), position: Vec2::new(0.0, 0.0), - z_index: 0.9999, + z_index: 0.0, }; for entity in node_query .iter_entities(world) @@ -57,7 +57,7 @@ fn update_node_entity(world: &mut SubWorld, entity: Entity, parent_quad: Quad) - return Some(Quad { size: quad.size, position: quad.position - quad.size / 2.0, - z_index: quad.z_index - UI_Z_STEP, + z_index: quad.z_index + UI_Z_STEP, }); } } @@ -69,6 +69,6 @@ fn update_node_entity(world: &mut SubWorld, entity: Entity, parent_quad: Quad) - fn process_child_result(_parent_result: Quad, child_result: Quad) -> Quad { // "earlier" children are sorted behind "later" children let mut result = child_result.clone(); - result.z_index -= UI_Z_STEP; + result.z_index += UI_Z_STEP; result } diff --git a/examples/2d/sprite.rs b/examples/2d/sprite.rs index 1b25261b83..7ec836092e 100644 --- a/examples/2d/sprite.rs +++ b/examples/2d/sprite.rs @@ -17,10 +17,6 @@ fn setup( .build() .add_entity(OrthographicCameraEntity::default()) .add_entity(SpriteEntity { - quad: Quad { - z_index: 0.5, - ..Default::default() - }, material: materials.add(texture_handle.into()), ..Default::default() }); diff --git a/examples/2d/sprite_sheet.rs b/examples/2d/sprite_sheet.rs index 368b5ff867..2c1029dc8e 100644 --- a/examples/2d/sprite_sheet.rs +++ b/examples/2d/sprite_sheet.rs @@ -42,7 +42,7 @@ fn setup( sprite: SpriteSheetSprite { index: 0, scale: 6.0, - position: Vec3::new(0.0, 0.0, -0.5), + position: Vec3::new(0.0, 0.0, 0.0), }, ..Default::default() })