Ruin0x11 / ElonaPlusCustom-GX

Elona+ variant based on Custom-G
134 stars 15 forks source link

UI Scaling #8

Closed DoctorGoat closed 3 years ago

DoctorGoat commented 3 years ago

Hello. I'm running the game on a 1920x1080 screen, and it's requiring me to either run fullscreen at 720p (which affects all my other windows) or be unreadable at 1080p. Nothing I've tried has reallly helped.

I know it might be nightmarish to do, but neither IntegerScaler or BorderlessGaming were able to help at all.

I'm not familiar enough with Hot Soup Processsor to give it a try on my own and I'm sorry for that. My best ideas, not knowing much, are to render at 1280x720 and display to a window at 1920x1080, but I don't remember if Windows would natively handle scalin like that.

If this isn't the right place to request this, please let me know where I should.

Ruin0x11 commented 3 years ago

Good news is that this is apparently doable. Thanks to the macro hackery of some genius I was able to retrofit high DPI support onto the entire codebase.

The branch is at feature/hidpi. Here is a binary for testing. To use it you can see the Display & Sound section of the options menu for the new high DPI options.

Note that turning on smooth scaling causes a lot of artifacting because of the way HSP renders things, and I'm not sure it can be worked around. But I'll see if I can add this in the next release.

DoctorGoat commented 3 years ago

Oof, for some reason I thought it was using DirectX/Direct3D. Does this version of HSP support shaders? Maybe bilinear or trilinear or something simple would help.

There are some very minor issues with non-linear scaling (1280x720 to 1920x1080, in this case). This is smooth scaling artifacting like you mentioned. https://i.gyazo.com/thumb/1200/42d62eb01b1835caee19f30a6a880c2d-jpg.jpg

Turning off smooth scaling gives me this, which shows something that I find interesting. The menu is no longer scaling incorrectly. https://i.gyazo.com/4f94a970bd23af10d4670139c45b082f.png

if it's possible to work around it and get it so it can render the menus without smooth scaling and the game with smooth scaling, that might help a little?

Ruin0x11 commented 3 years ago

The original HSP runtime that Elona runs on is based around bitmap blitting, basically taking parts of an image buffer and pasting them into the game window or elsewhere, so it isn't like it's hardware accelerated or anything. To explain, the "smooth scaling" option just sets a flag on the method that copies and resizes the image portions so they get smoothed over; it isn't configurable under the hood.

There is a runtime called HGIMG4 with proper DirectX/OpenGL support, but the rendering process there is different. Original HSP only redraws the screen when the program requests it, while HGIMG4 runs at a proper 60FPS rendering loop. Because that means the screen is cleared each frame, in Elona's case it would require a massive overhaul of the code to make sure everything is redrawn on a per-frame basis, which I'm not sure is feasable. Not to mention that bitmap blitting is way different of a paradigm than using shaders for rendering, so it would be likely that even more architectural changes would be needed.

From what I understand it's possible to call the Win32 API for things like changing the window flags for windowed/fullscreen. There was one person who managed to code a system for copying the final output window into a backbuffer and upscaling it using StretchBlt, but that wouldn't be a HiDPI thing, it would just be an upscale.

Also, could you explain what you mean by "menu scaling?" Is it the UI in the screenshots or things like in-game popups? If you mean the message window, then that's a symptom of the same issue with the smoothing - it seems that the algorithm is prone to texture bleeding along image boundaries.

DoctorGoat commented 3 years ago

I think we've got a pretty good solution at this point. It was things like the UI at the bottom of the smoothed screenshot that I was noticing having trouble tiling.

Ruin0x11 commented 3 years ago

Added in 2.06fix.2.0.