Render gizmo line widths in logical pixels
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Currently, gizmo lines are rendered in physical pixels, and there doesn't appear to be any way to consistently render them in logical pixels. This results in different appearance on different screens.
For comparison, bevy ui renders borders in logical pixels.
## What solution would you like?
There should at least be an option to render lines with pixel widths given in logical pixels. The logical pixel width would be multiplied by the window (or render target) scale factor to compute the physical pixel width. I might suggest that logical pixels should be the default configuration, if it is optional.
Line widths may be given in [Val](https://docs.rs/bevy/latest/bevy/prelude/enum.Val.html) units for consistency with bevy ui, though I'm not sure units other than `Px` would be useful.
The same configuration should apply to joins and end caps as well.
Physical line width, as derived from logical line width, should work when multiple views are rendered, and should be adjusted in response to changes in render target scale factor: e.g. when moving a window between monitors with different scale factors.
## What alternative(s) have you considered?
One possible workaround is to observe the [Window](https://docs.rs/bevy/latest/bevy/prelude/struct.Window.html) component for scale factor and multiply the value passed to the `GizmoLineConfig` width property. The problem with this approach is that it assumes there is only one Window. If there are multiple windows or render targets, lines will be drawn inconsistently across them.
## Additional context
It may also be helpful to add scale factor to the `ViewUniform`, so physical line widths can be computed inside the shader for this and other custom effects.
Contributor guide
Assessment
This issue has not been assessed yet.