komadori / bevy_mod_outline

Apache License 2.0
123 stars 10 forks source link

Custom viewports cause stretched outlines #5

Closed TheRawMeatball closed 2 years ago

TheRawMeatball commented 2 years ago

Using this crate with custom scaled viewports leads to unnatural artefacts.

commands.spawn_bundle(Camera3dBundle {
    camera: Camera {
        viewport: Some(Viewport {
            physical_size: UVec2 { x: 2000, y: 200 },
            ..Default::default()
        }),
        ..Default::default()
    },
    transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
    ..default()
});

Using the code above to spawn the camera in the shapes example should be enough to reproduce the bug.

komadori commented 2 years ago

The thickness of the outline is specified in logical screen pixels, so I would expect that they become relatively thicker when you shrink the viewport.

I'm not sure how to interpret the 2000x200 aspect ratio of the viewport. This is obviously the cause of the outlines being thicker along the Y axis than the X axis. However, the scene is not being rendered with this aspect. The window isn't even that big. The rendering appears to be scaled to fit in the right-hand size of the render target, and those are the dimensions which need to be used in calculating the scaling factors.

komadori commented 2 years ago

It's not really clear what the correct behaviour should be, so I'm closing this for now. Perhaps it is a bevy issue that the size of the rendering doesn't match the physical_size? Please open a new issue if you have a clearer example/explanation. Thanks.