ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.72k stars 625 forks source link

All GoldSrc games (besides Half-Life) still have incorrect HUD scaling #3548

Open Asphaltian opened 12 months ago

Asphaltian commented 12 months ago

Title says it all. I'll upload some screenshots to compare with the post-25th Anniversary Update version of Half-Life.

Half-Life: Blue Shift: Screenshot 2023-11-22 163023

Half-Life: Opposing Force: Screenshot 2023-11-22 162843

Day of Defeat: Screenshot 2023-11-22 163456

Team Fortress Classic: Screenshot 2023-11-22 164646

Counter-Strike: Condition Zero Deleted Scenes: Screenshot 2023-11-22 164949

Not related, but CS:CZDS also has it's world map completely broken: Screenshot 2023-11-22 165612

Deathmatch Classic: Screenshot 2023-11-22 165202

Ricochet: Screenshot 2023-11-22 165452

Finally, to compare with the current version of Half-Life: Screenshot 2023-11-22 163221

sabianroberts commented 12 months ago

This is because for the large HUD the sprites had to be converted to a larger format file to be shown as large as they are. For some reason it isn't the old sprites rendered in a larger scale.


From: Asphaltian @.> Sent: Wednesday, November 22, 2023 9:11:28 AM To: ValveSoftware/halflife @.> Cc: Subscribed @.***> Subject: [ValveSoftware/halflife] All GoldSrc games (besides Half-Life) still have incorrect HUD scaling (Issue #3548)

Title says it all. I'll upload some screenshots to compare with the post-25th Anniversary Update version of Half-Life.

Half-Life: Blue Shift: [Screenshot 2023-11-22 163023]https://user-images.githubusercontent.com/86578963/284841764-d2ed19c2-8019-4c87-8784-5fa6bb1fda26.png

Half-Life: Opposing Force: [Screenshot 2023-11-22 162843]https://user-images.githubusercontent.com/86578963/284841958-26272763-be6c-4838-a3a7-54fd7fd7a466.png

Day of Defeat: [Screenshot 2023-11-22 163456]https://user-images.githubusercontent.com/86578963/284842205-f1dd51d8-0c45-4228-92ff-81a98f7a1846.png

Team Fortress Classic: [Screenshot 2023-11-22 164646]https://user-images.githubusercontent.com/86578963/284843025-bd290a43-0b8a-422b-af8a-dcfac74e1250.png

Counter-Strike: Condition Zero Deleted Scenes: [Screenshot 2023-11-22 164949]https://user-images.githubusercontent.com/86578963/284843890-2a6152ac-18ef-4eb9-a9be-f9363d741407.png

Not related, but CS:CZDS also has it's world map completely broken: [Screenshot 2023-11-22 165612]https://user-images.githubusercontent.com/86578963/284845789-d1ade173-f458-4d61-a261-ba13a32c000b.png

Deathmatch Classic: [Screenshot 2023-11-22 165202]https://user-images.githubusercontent.com/86578963/284844489-6c3a38aa-a9fc-4a0d-9ea9-c7e99f4c9b9d.png

Ricochet: [Screenshot 2023-11-22 165452]https://user-images.githubusercontent.com/86578963/284845241-ab3a1945-e980-4546-b5cc-7653aab2a605.png

Finally, to compare with the current version of Half-Life: [Screenshot 2023-11-22 163221]https://user-images.githubusercontent.com/86578963/284846807-8c7dbde4-003f-4e61-b059-4da02d31d457.png

— Reply to this email directly, view it on GitHubhttps://github.com/ValveSoftware/halflife/issues/3548, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHQIMESKQBVCA3GUUEZX72DYFW6UBAVCNFSM6AAAAAA7V4EGTCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYDKOBYG43DQMY. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Asphaltian commented 12 months ago

This is because for the large HUD the sprites had to be converted to a larger format file to be shown as large as they are. For some reason it isn't the old sprites rendered in a larger scale.

Makes sense, since I was browsing through the game files and came across duplicates of HUD sprites in two folders named 2560 and 1280. Still a weird solution though...

SamVanheer commented 12 months ago

This is because for the large HUD the sprites had to be converted to a larger format file to be shown as large as they are. For some reason it isn't the old sprites rendered in a larger scale.

The engine does not provide a way to draw sprites at a different size than their native one in a manner that works in Software mode. The triangle API doesn't work in that mode which is the only way to do it.

3doplayer67484 commented 12 months ago

https://steamcommunity.com/sharedfiles/filedetails/?id=2265943705&searchtext=hud+sprites I would recommend using this as a temp solution to fix Opposing Force and Blue Shift's hud to match the update the hud got in the base game

Asphaltian commented 12 months ago

Recent update made CS:CZDS's world map slightly less broken now (still doesn't stretch properly): Screenshot 2023-11-23 030415

Counter-Strike also didn't have its sprite resolution increased (guessing that will be later): Screenshot 2023-11-23 030838

ZekyTheWolf commented 12 months ago

Replying to https://github.com/ValveSoftware/halflife/issues/3548#issuecomment-1823366411

Would add,

Menus need some spacing between items on higher res (1366x768 and higher)... Also, chat is bigger then classic hud messages...

RedFire512 commented 11 months ago

This is because for the large HUD the sprites had to be converted to a larger format file to be shown as large as they are. For some reason it isn't the old sprites rendered in a larger scale.

The engine does not provide a way to draw sprites at a different size than their native one in a manner that works in Software mode. The triangle API doesn't work in that mode which is the only way to do it.

Valve had created brand new spites specifically for the HL25 update that were scaled up, so that the HUD would display with the same scaling it would back on the 4:3 CRT screens from 1998.

What'll have to be done for all the other GoldSrc games is to create the files that do the same thing.

sabianroberts commented 11 months ago

Replying to https://github.com/ValveSoftware/halflife/issues/3548#issuecomment-1826976844

APITA for modders with custom HUD sprites, unfortunately. I added custom HUD sprites to my mod 2 weeks ago and after the HL25 update I had to practically make them again. The HL25 features are really really cool but some of them require double effort than before.

imshvc commented 9 months ago

A simple implementation of hud_scale would've solved all of these problems. Instead, the developers resorted to scaling the old hud assets to larger ones and then just referencing those in the hud.txt file. If no workaround is made, I might have to figure this out on my own then. It is aggresively painful to play these games on HD resolutions.

imshvc commented 9 months ago

There is a hardcoded limit in the client.dll of Counter-Strike (and other games I suppose) that limits the hud.txt parsing to only load the 640 variant.

I tested this by programatically scanning for the value 640 in the binary, and changing each one until I could verify that the file was loading with this line:

radar 1280 radar1280 0 0 256 256

Another problem is that the HUD is controlled by client.dll too, that means that even if I managed to do everything correct, I still wouldn't get the expected result because I'm unable to scale the containers that contain the HUD sprites themselves.

image

If anyone more knowledgeable can shed a light on this, I'd appreciate it.

0Ky commented 9 months ago

@oxou I've been looking into the HUD sprite loading mechanism within the Half-Life SDK, particularly in the CHud::VidInit function, and I believe I can provide some insight regarding the resolution limitation issue you mentioned for Counter-Strike and potentially other mods.

In the CHud::VidInit function from the Half-Life SDK, the code determines the HUD sprite resolution to load based on the screen width. If the screen width is less than 640 pixels, it uses the 320 resolution sprites, otherwise it defaults to the 640 resolution sprites. Here's the relevant part of the code: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/cl_dll/hud.cpp#L428-L431

This effectively hardcodes the maximum sprite resolution to 640, as you mentioned. However, when disassembling the recent update of Half-Life's client.dll, it appears there are additional conditions that take into account higher screen resolutions, extending the logic to potentially support 1280 and 2560 resolution sprites based on both screen width and height. Here's the high-level interpretation of the relevant logic from the disassembled function.

if (gHUD.m_scrinfo.iWidth < 2561) {
    if (gHUD.m_scrinfo.iWidth > 1279) {
        m_iRes = 1280; // Resolution set to 1280 for widths between 1280 and 2560
    } else if (gHUD.m_scrinfo.iWidth < 640) {
        m_iRes = 320; // Resolution set to 320 for widths less than 640
    } else {
        m_iRes = 640; // Resolution set to 640 for widths between 640 and 1279
    }
} else if (gHUD.m_scrinfo.iHeight < 1601) {
    m_iRes = 1280; // Resolution set to 1280 for heights less than 1601 when width is 2561 or more
} else {
    m_iRes = 2560; // Resolution set to 2560 for heights 1601 or more
}

Warning: This interpretation is derived from disassembled code and may not fully capture the actual source code.

This expanded logic in the updated client.dll of Half-Life suggests that the game can now select higher resolution HUD sprites based on the screen's resolution, which is not reflected for mods like Counter-Strike. This discrepancy might be why mods are not automatically benefiting from the ability to load higher resolution HUD sprites.

imshvc commented 9 months ago

@0Ky Thank you for the information and your time, this is good to know - but what a bummer, couldn't they use simple multiplication to be able to target higher resolutions (640, 1280, 2560, 3840, etc)

I might take a look at the client.dll again and see if I'm able to modify the code flow so it allows reading all entries (just for fun).

By the way, this repository does not reflect the latest changes of the update? Or is that something planned for the future (if you have any info on this)

0Ky commented 9 months ago

@oxou I've taken another look to address the other issue you mentioned regarding the radar's HUD bounding box limitation. It appears this limitation is hardcoded into the client.dll of Counter-Strike 1.6, specifically within the CHudHealth::VidInit() function, which sets the radar's HUD bounding box to 128x128. Below is the relevant section of the disassembled function:

int CHudHealth::VidInit(void) {

    //...
    m_HUD_radar = gHUD.GetSpriteIndex("radar");
    m_HUD_radaropaque = gHUD.GetSpriteIndex("radaropaque");

    gHUD.GetSpriteRect(m_HUD_radar).right = 128;
    gHUD.GetSpriteRect(m_HUD_radar).bottom = 128;

    gHUD.GetSpriteRect(m_HUD_radaropaque).right = 128;
    gHUD.GetSpriteRect(m_HUD_radaropaque).bottom = 128;
    //...

    return 1;
}

Warning: This interpretation is derived from disassembled code and may not fully represent the original source. Also, it's a condensed version, with unrelated details omitted for clarity.

By the way, this repository does not reflect the latest changes of the update?

That is correct, this repository has been inactive for over a decade, therefore any updates to the game since then, including the 25th anniversary update, have not been reflected in this repository.

Or is that something planned for the future

Unfortunately, I have no information on this. I hope they do.

Vicjo24 commented 2 months ago

If you all have found a solution or a modification or something, I would greatly appreciate it if you would let me know. Thanks in advance.