fishfolk / jumpy

Tactical 2D shooter in fishy pixels style. Made with Rust-lang 🦀 and Bevy 🪶
https://fishfolk.org/games/jumpy/
Other
1.64k stars 118 forks source link

Steam Deck: Graphics scaled up too big #904

Closed MaxCWhitehead closed 6 months ago

MaxCWhitehead commented 7 months ago

The bevy_window crate computes scale factor in WindowResolution based on OS reported pixel density. This seems to not end up right on the deck.

Setting scale_factor_override = 1.0 fixes graphics scaling issues on deck, from my research this is probably less of an issue with bevy's computation of scale factor and more that the deck doesn't report accurate values, but will look into it more.

Worse case scenario we have to detect steamdeck and adjust this value.

EDIT: The TLDR of my comments is that I think we should include some special launch shell scripts for linux distribution through steam. If using steam deck display, need to set a variable to fix scale. Doing this in shell / on game launch side keeps the options close to user, and doing this in engine / game code is harder and less accessible to tweak.

MaxCWhitehead commented 7 months ago

It seems the scale factor can also be modified by setting environment variable: WINIT_X11_SCALE_FACTOR.

I tested this in a few configurations, when using the deck's display, we want to set scale to 1. However, when using an external display (like a tv in my case), the default scale factor is appropriate, and we don't want to override it. Scale factor can be adjusted in the OS display scaling, and forcing to 1 will prevent this function from working in desktop mode on deck.

My current thoughts for fixing:

I'm preferring setting environment variable so that this behavior is easier to control by user. For some reason this fails or they want to override our override, they can set env var, and we will not apply it if already set. Otherwise, we could have this in a game config file or launcher settings too.

MaxCWhitehead commented 7 months ago

Spent some more time thinking about this - determining if is steam deck isn't hard, but. determining the resolution of monitor before bevy_window / winit bootstrap change the scale factor override is annoying.

Either have to pull in winit / xrandr api and use it, or maybe init bevy_window/winit and query monitor resolution later on and then update scale factor (if possible).

I've decided I think it's best if we keep this simple and do none of this.

For distribution on linux + steam, we can include two launch scripts: jumpy_desktop.sh and jumpy.sh. One with scale override for steam deck, and the other without for OS-configured scaling for high-res displays.

The default script can use shell commands to guess which it should launch (are we steam deck native display or not), and worst case scenario on steam deck desktop or linux desktop the user may launch the unscaled script to avoid any magic we are doing here.

With that in mind, not really proposing any changes to bones here. Probably can move this issue to Jumpy as a reminder to address this when packaging for linux on steam.

zicklag commented 7 months ago

Transferred to the Jumpy repo. 👍️