mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 14:40:19 +00:00
render: draw in back-to-front mode to be safe (until we can do both at the same time). expand texture example
This commit is contained in:
parent
3ee8aa8b0f
commit
2c74560283
2 changed files with 19 additions and 4 deletions
|
@ -103,7 +103,7 @@ impl Node for MainPassNode {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut draw_state = DrawState::default();
|
let mut draw_state = DrawState::default();
|
||||||
for visible_entity in visible_entities.iter() {
|
for visible_entity in visible_entities.iter().rev() {
|
||||||
let draw = if let Some(draw) = world.get_component::<Draw>(visible_entity.entity) {
|
let draw = if let Some(draw) = world.get_component::<Draw>(visible_entity.entity) {
|
||||||
draw
|
draw
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -34,13 +34,20 @@ fn setup(
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
// this material modulates the texture to make it red
|
// this material modulates the texture to make it red (and slightly transparent)
|
||||||
let modulated_material_handle = materials.add(StandardMaterial {
|
let red_material_handle = materials.add(StandardMaterial {
|
||||||
albedo: Color::rgba(1.0, 0.0, 0.0, 0.5),
|
albedo: Color::rgba(1.0, 0.0, 0.0, 0.5),
|
||||||
albedo_texture: Some(texture_handle),
|
albedo_texture: Some(texture_handle),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// and lets make this one blue! (and also slightly transparent)
|
||||||
|
let blue_material_handle = materials.add(StandardMaterial {
|
||||||
|
albedo: Color::rgba(0.0, 0.0, 1.0, 0.5),
|
||||||
|
albedo_texture: Some(texture_handle),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
|
||||||
// add entities to the world
|
// add entities to the world
|
||||||
command_buffer
|
command_buffer
|
||||||
.build()
|
.build()
|
||||||
|
@ -48,6 +55,14 @@ fn setup(
|
||||||
.add_entity(MeshEntity {
|
.add_entity(MeshEntity {
|
||||||
mesh: quad_handle,
|
mesh: quad_handle,
|
||||||
material: material_handle,
|
material: material_handle,
|
||||||
|
translation: Translation::new(0.0, -1.5, 0.0),
|
||||||
|
rotation: Rotation::from_euler_angles(0.0, std::f32::consts::PI / 3.0, 0.0),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
// textured quad - modulated
|
||||||
|
.add_entity(MeshEntity {
|
||||||
|
mesh: quad_handle,
|
||||||
|
material: red_material_handle,
|
||||||
translation: Translation::new(0.0, 0.0, 0.0),
|
translation: Translation::new(0.0, 0.0, 0.0),
|
||||||
rotation: Rotation::from_euler_angles(0.0, std::f32::consts::PI / 3.0, 0.0),
|
rotation: Rotation::from_euler_angles(0.0, std::f32::consts::PI / 3.0, 0.0),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -55,7 +70,7 @@ fn setup(
|
||||||
// textured quad - modulated
|
// textured quad - modulated
|
||||||
.add_entity(MeshEntity {
|
.add_entity(MeshEntity {
|
||||||
mesh: quad_handle,
|
mesh: quad_handle,
|
||||||
material: modulated_material_handle,
|
material: blue_material_handle,
|
||||||
translation: Translation::new(0.0, 1.5, 0.0),
|
translation: Translation::new(0.0, 1.5, 0.0),
|
||||||
rotation: Rotation::from_euler_angles(0.0, std::f32::consts::PI / 3.0, 0.0),
|
rotation: Rotation::from_euler_angles(0.0, std::f32::consts::PI / 3.0, 0.0),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
Loading…
Reference in a new issue