Closed
Description
Bevy version
v0.8.0
Relevant system information
AdapterInfo { name: "NVIDIA GeForce GTX 1080", vendor: 4318, device: 7040, device_type: DiscreteGpu, backend: Vulkan }
Ubuntu 22.04
What you did
I have modified the 3d_scene.rs example to give alpha = 0.3 to the cube and add another cube inside, itself with an alpha!=1.
Full code :
//! A simple 3D scene with light shining over a cube sitting on a plane.
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.run();
}
/// set up a simple 3D scene
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// plane
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..default()
});
// cube
commands
.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgba(0.8, 0.7, 0.6, 0.3).into()),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
})
.with_children(|cube| {
cube.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.1 })),
material: materials.add(Color::rgba(0.8, 0.7, 0.6, 0.5).into()),
..default()
});
});
// light
commands.spawn_bundle(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
// camera
commands.spawn_bundle(Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
What went wrong
When running this modified example, the cube inside the main cube is 'flickering', its render color is changing each frame.
Because nothing other is changing in the scene, I did expect he rendered color to be stable across frames.
See short video:
https://user-images.githubusercontent.com/18518188/184179259-a0f4cd2c-88fb-4e91-b799-112ba4f9ceb2.mp4
Additional information
- If the internal cube has alpha=1 there is no flickering issue, only if internal cube 0.0 < alpha < 1.0
- If the internal cube has alpha=0 there is no issue either, the internal cube is properly always invisible.