Accurate HUD Scaling at Lower Resolutions

Sun May 02, 2021 12:49 pm

I've noticed when using 640x400 or 320x200 mode on my 2880x1800 HiDPI laptop LCD that the HUD's pixels seem to be scaled correctly even with linear filtering set to None...

But, if I switch to a Normal + 0.25 scale or use the "Lowest Possible Scale" mode the HUD's pixels aren't scaled properly (referring to vertically mostly) - some lines/pixels look like they're sometimes double-height where others are correct.

Is there a way to address this so I can play in widescreen with chunky pixels and have a HUD that appears to be scaled correctly?

Thanks!
Last edited by speedy on Sun May 02, 2021 10:36 pm, edited 1 time in total.

Re: Accurate HUD Scaling at Lower Resolutions

Sun May 02, 2021 2:35 pm

If you use a size too close to your actual resolution that isn't a whole factor, such artifacts are unavoidable.

Let's say you want to stretch 200 pixels to a display size of 300. The only way to achieve this is to double each second pixel so you have a display of 1/2/1/2 and so on.
Those small sizes like 320x200 and 640x400 are only 1/5th or 1/6th, so you alternate between a scaling of 5/6 or 10/11 screen pixels per source pixel at which the effect is barely noticable. The closer you get to your real screen size, the more noticable it gets.

Re: Accurate HUD Scaling at Lower Resolutions

Mon May 03, 2021 12:08 am

You need to do the math yourself to set custom scaling like this...

ScaledY / NativeY = Y * NativeX = X * 1.2 = ScaledX

You'll always know your ScaledY because that's the vertical resolution you want to achieve (400p in my case). You're solving for the ScaledX.

Then run the command:
vid_setscale ScaledX ScaledY 0 1.2

For example, my laptops LCD is 2880x1800 so I'd calculate like this:
400 / 1800 = .222 * 2880 = 640 * 1.2 = 768

So I ran the command:
vid_setscale 768 400 0 1.2

Now my HUD looks perfect and I have a nice 400p widescreen render resolution.

Rachel showed me on Discord how to do this (THANK YOU!).
Last edited by speedy on Mon May 03, 2021 9:36 am, edited 1 time in total.

Re: Accurate HUD Scaling at Lower Resolutions

Mon May 03, 2021 7:52 am

speedy wrote:Rachel showed me on Discord how to do this (THANK YOU!).

You're welcome.

It shouldn't be this hard to do it, but the main reason why I haven't extended the code further is due to extension after extension the code has been in desperate need of refactoring that I just haven't gotten around to yet. It's a mess, and I am ashamed that I let it get so bad, but it's why I am not adding features to it right now.

Re: Accurate HUD Scaling at Lower Resolutions

Mon May 31, 2021 4:54 pm

I wanted to add a couple more details for anyone else who may stumble on this thread...

I had to set r_noaccel true for scaling to avoid scaling issues on certain sprites on my weapon. Rachel mentioned to me that this is likely due inefficiencies with the float datatype. You can see the issue here: https://youtu.be/nwiFsROPJtQ

Doing this also requires switching to the "Doom Software Renderer" or "True Color SW Renderer" which I preferred regardless because of the vanilla look I was going for.