Open younggam opened 1 year ago
Do you see this on the minimal
example?
Ok but i'll do it later because I'm on part time job.
Imvironment is Windows 10, gtx 2060, 144hz from FiFo
It quite works well. No blinking at all. But when I copy-pasted code to my project, it blinks.
fn setup(
mut commands: Commands,
state: Res<GlobalState>,
textures: Res<Textures>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut polylines: ResMut<Assets<Polyline>>,
mut polyline_materials: ResMut<Assets<PolylineMaterial>>,
windows: Res<Windows>,
) {
//camera
commands
.spawn_bundle(Camera3dBundle {
transform: Transform::from_xyz(-4.0, 10.0, -5.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
})
.insert(state.mark());
//crosshair
let window = windows.primary();
commands
.spawn_bundle(ImageBundle {
image: textures[UI][UI_CROSSHAIR].clone().into(),
style: Style {
size: Size::new(Val::Px(32.), Val::Px(32.)),
position_type: PositionType::Absolute,
position: UiRect::new(
Val::Px(window.width() * 0.5 - 16.),
Val::Undefined,
Val::Undefined,
Val::Px(window.height() * 0.5 - 16.),
),
..default()
},
..default()
})
.insert(state.mark());
//directional light
commands
.spawn_bundle(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 32000.0,
..default()
},
transform: Transform {
rotation: Quat::from_euler(EulerRot::ZYX, 0., PI * 0.25, -PI * 0.4),
..default()
},
..default()
})
.insert(state.mark());
//plane
commands
.spawn_bundle(PbrBundle {
mesh: meshes.add(Plane { size: 100.0 }.into()),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..default()
})
.insert(state.mark());
//x axis line
commands
.spawn_bundle(PolylineBundle {
polyline: polylines.add(Polyline {
vertices: vec![Vec3::ZERO, Vec3::X * 100.],
..default()
}),
material: polyline_materials.add(PolylineMaterial {
color: Color::RED,
perspective: true,
..default()
}),
..default()
})
.insert(state.mark());
//y axis line
commands
.spawn_bundle(PolylineBundle {
polyline: polylines.add(Polyline {
vertices: vec![Vec3::ZERO, Vec3::Y * 100.],
..default()
}),
material: polyline_materials.add(PolylineMaterial {
color: Color::GREEN,
perspective: true,
..default()
}),
..default()
})
.insert(state.mark());
//z axis line
commands
.spawn_bundle(PolylineBundle {
polyline: polylines.add(Polyline {
vertices: vec![Vec3::ZERO, Vec3::Z * 100.],
..default()
}),
material: polyline_materials.add(PolylineMaterial {
color: Color::BLUE,
perspective: true,
..default()
}),
..default()
})
.insert(state.mark());
}
Can you please try to make a minimal reproduction? If it doesn't happen in the minimal example, but does happen in the code above, there must be something in that code that is causing this to happen.
I know it sounds very weird, I couldn't reproduce blinking again. There was few change from above. But after few experiments, I found a noticeable other bug seems very related with blinking. That is, If there are many poly lines, their perspective value application highly depends on their spawn order. If all lines that perspective is false are spawned after even one perspective true line, they become as if perspective is true.
If all lines that perspective is false are spawned after even one perspective true line, they become as if perspective is true.
Interesting! I think I understand how to tackle reproducing this.
While above gif seems line randomly blinks because of low frame, actually it blinks periodically and short term.
Below is the spawn of line with set off perspective since default value of perspective is false.