H-uru / Plasma

Cyan Worlds's Plasma game engine
http://h-uru.github.io/Plasma/
GNU General Public License v3.0
205 stars 81 forks source link

Game is pixelated when using HiDPI Scaling on Windows #636

Closed Hoikas closed 1 year ago

Hoikas commented 4 years ago

Conversation with @cwalther on IRC 2020-02-29 indicates problems with playing the game when Windows scaling is enabled. He reports the image is improperly scaled using nearest neighbor interpolation when playing in full screen. There is a previous report of chicanery as well.

[17:16:21] <CWalther> tweak anything in my Windows display settings? It’s set to 200%, “fix scaling” off and no custom scaling.
[17:16:53] <CWalther> *rendered at 1920x1080
[17:26:27] <Doobes> Hoikas would probably have the best answer for that as he's been able to grab high res screenshots of things.
[17:27:24] <Doobes> He may currently be AFK or busy with something though.
[17:27:27] <CWalther> Yeah, I remembered that so it seems odd.
[17:28:30] <Doobes> Wish I could help, but I'm still stuck in 1080p land. :D
[17:32:30] <CWalther> Chiso is looking fantastic in 1080p! :)
[17:47:03] <Hoikas> I haven't seen any issues on my 3840x1600 display, CWalther
[17:47:42] <CWalther> I almost suspected as much, otherwise you’d have fixed them :)
[17:48:47] <CWalther> I can try playing with the Windows settings.
[17:50:03] <Hoikas> I know we had a complaint recently from someone playing with scaling enabled, but I think that was a case of the UI being offscreen
[17:51:18] <CWalther> With 100% scale it looks good (but I don't want my Windows desktop that tiny).
[17:51:33] <Hoikas> :)
[17:52:27] <Hoikas> I don't touch scaling myself. I invariantly use programs that look terrible with it on. Instead, I "just" (a year ago) bought an ultrawide monitor
[17:54:44] <CWalther> With 200% and “fix scaling for apps” enabled (whatever that is), no difference, still blocky.
[17:57:06] <CWalther> With “custom scaling” 300%, pixel-tripled blocky.
[17:57:32] <Hoikas> I'm not sure I understand "pixel-doubled" and "pixel-tripled"
[17:58:01] <CWalther> What I mean is that groups of 2x2 or 3x3 physical pixels have the same color to make one image pixel.
[17:58:17] <Hoikas> ok
[17:58:41] <CWalther> As if you scaled up a lower-res image using nearest neighbor interpolation.
[17:59:07] <Hoikas> that very well could be what is actually happening
[18:00:24] <CWalther> I guess so. MOULa by the way does not do that, so it probably has to do with resolution-awareness added in newer WIndows SDKs or somesuch.
[18:00:53] <Hoikas> or that "fullscreen" is just a borderless window for us
[18:01:25] <CWalther> Good point, I haven't tried what happens in windowed mode.
[18:02:40] <Hoikas> "Desktop applications must tell Windows if they support DPI scaling. By default, the system considers desktop applications DPI unaware and bitmap-stretches their windows."
[18:03:22] <Hoikas> I believe wingdi uses a crummy nearest-neighbor type filter by default
[18:03:43] <Hoikas> (but dwm should be DX, not gdi...)
[18:04:46] <CWalther> I read those docs once when I was working on a Windows app… it's horribly complicated. There are multiple stages of awareness.
[18:05:11] <Hoikas> I've skimmed them before and am currently filled with dread.
[18:11:50] <Hoikas> This actually does not look too hard to fix for Windows 10 1703 and later
[18:12:30] <Hoikas> As for anything earlier than that... "update to a recent OS"
[18:15:35] <CWalther> In windowed mode (with my original 200% setting) it looks like it renders either at the chosen resolution, or if that is larger than 1920x1080 squished down to that (not even preserving aspect ratio), and then pixel-doubles it.
[18:16:16] <CWalther> “update to a recent OS” – I’m fine with that as far as Windows is concerned
[18:16:56] <Hoikas> strange stuff. I'll have to look at this when my screen isn't full
[18:17:09] * Hoikas shivers at the idea of playing with the Windows scaling features
[18:17:34] <CWalther> Eh, no pressure. I was just wondering if it was a known problem.
[18:19:05] <Hoikas> it wasn't--thanks for bringing it up!
[18:19:52] <CWalther> (Of course, going further it would also be nice if it would take into account the Windows scaling factor for things like the cursor and the mouseover player name text (was that “plates” too?), so these wouldn’t be tiny for me.)
[18:21:12] <Hoikas> from what I see, windows will provide client RECT if we opt into dpi awareness v2, so hopefully if we resize to that rect, everything should be fine
[18:21:58] <Hoikas> of course, my understanding might be completely wrong as well ^_^
[18:22:43] <CWalther> I don't remember how you opt in - was it a manifest setting, or a function to call?
[18:24:27] <Hoikas> in Windows 8 it was the former, but in Windows 10 1607, we can use SetThreadDpiAwarenessContext
[18:25:02] <CWalther> Ugh, thread-specific?
[18:25:46] <Hoikas> SetProcessDpiAwarenessContext was added in 1703, it seems
[18:26:03] <Hoikas> "It is recommended that you set the process-default DPI awareness via application manifest. See Setting the default DPI awareness for a process for more information. Setting the process-default DPI awareness via API call can lead to unexpected application behavior."
[18:27:08] <Hoikas> the per-thread function seems to be more flexible. Windows are generally bound to a specific thread, so it makes sense to use that
cwalther commented 4 years ago

Some screenshots for clarification:

Actual behavior with Windows set to 200%: image

Acceptable expected behavior (matching MOULa; taken with Windows set to 100%): image

Preferred expected behavior (mockup) – Windows scaling applied to cursor: image

There is a slight change in scale between the actual and expected behavior that I hadn’t noticed before. In the actual view, the controls at the bottom (Relto book, KI, wrench, X) are actually cut off a little.

hhhenry’s solution

Run UruExplorer compatibility mode > change DPI settings > Override high DPI scaling behavior scaling performed by: Application

is a viable workaround.

Hoikas commented 3 years ago

Additional reports indicate that HiDPI cause the client to render in offscreen areas and may reintroduce the dreaded mouselook bug.

Sources:

dpogue commented 1 year ago

Was this solved by #1269?

Hoikas commented 1 year ago

It should be 👍