Skip to content
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

Line is blinking if perspective set to false #35

Open
younggam opened this issue Nov 6, 2022 · 6 comments
Open

Line is blinking if perspective set to false #35

younggam opened this issue Nov 6, 2022 · 6 comments

Comments

@younggam
Copy link

younggam commented Nov 6, 2022

제목없음3

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.

PolylineBundle {
        transform: Transform::from_xyz(0., 3., -10.),
        polyline: polylines.add(Polyline {
            vertices: vec![Vec3::new(2., 2., 0.), Vec3::new(-2., -2., 0.)],
            ..default()
        }),
        material: polyline_materials.add(PolylineMaterial {
            color: Color::WHITE,
            ..default()
        }),
        ..default()
}
@aevyrie
Copy link
Collaborator

aevyrie commented Nov 10, 2022

Do you see this on the minimal example?

@younggam
Copy link
Author

younggam commented Nov 10, 2022

Ok but i'll do it later because I'm on part time job.

Imvironment is Windows 10, gtx 2060, 144hz from FiFo

@younggam
Copy link
Author

younggam commented Nov 10, 2022

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());
}

@aevyrie
Copy link
Collaborator

aevyrie commented Nov 10, 2022

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.

@younggam
Copy link
Author

younggam commented Nov 13, 2022

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.

@aevyrie
Copy link
Collaborator

aevyrie commented Nov 13, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants