Skip to content

Fix split-screen UI wrong positioning on window resize#989

Merged
codeHusky merged 2 commits intosmartcmd:mainfrom
MrTheShy:fix-ui-wrong-resize
Mar 9, 2026
Merged

Fix split-screen UI wrong positioning on window resize#989
codeHusky merged 2 commits intosmartcmd:mainfrom
MrTheShy:fix-ui-wrong-resize

Conversation

@MrTheShy
Copy link
Contributor

@MrTheShy MrTheShy commented Mar 9, 2026

Description

Fix split-screen HUD, Chat, and Tooltips rendering incorrectly when the Windows64 game window is below 1080p.

Changes

Previous Behavior

In 2-player vertical split (SPLIT_LEFT/RIGHT) at window heights below 1080, HUD elements (crosshair, hotbar, hearts, player name) shifted downward, and Chat/Tooltips drifted in the wrong direction. The issue worsened as the window got smaller — at 720p the HUD was noticeably off-center, and at very small windows elements could move entirely off-screen. Horizontal split and quadrant modes were not affected.

Root Cause

Two separate bugs, both originating from 4J's assumption that these platforms always run at 1080p:

1. ComputeTileScale clamp (HUD, Chat, Tooltips)

ComputeTileScale computes scale = max(scaleW, scaleH) then clamps it to >= 1.0 to prevent the SWF from being rendered too small in quadrant mode. In vertical split, tileHeight = screenH. On consoles this equals the movie height (1080), so scaleH = 1.0 and the clamp has no effect. On PC at sub-1080 heights (e.g. 900), scaleH = 900/1080 = 0.833 gets clamped to 1.0, leaving the SWF at native 1920x1080 and cropping the bottom. repositionHud then passes visibleH = 900 to ActionScript, which sees less than the full height and shifts elements downward to "center" them.

2. ComputeSplitContentOffset (Chat, Tooltips)

Chat and Tooltips applied a position offset from ComputeSplitContentOffset to the tile origin. This function returned (0,0) at the design resolution (1920x1080) but computed incorrect offsets at any other size — Player 1 tooltips drifted left/right in vertical split and up/down in horizontal split. Player 2 was unaffected because the function only applied offsets to LEFT/TOP viewports.

New Behavior

Split-screen HUD, Chat, and Tooltips render correctly at any window resolution on Windows64. At 1080p and above the rendering is unchanged. Below 1080p the overlays scale down to fit the full SWF height, keeping all elements in their designed positions.

Fix Implementation

HUD (UIScene_HUD::render): After ComputeTileScale, added a vertical-split override that allows the scale to go below 1.0 when the window height is less than the movie height. This scales the SWF down to fit the full height, so repositionHud passes visibleH = movieHeight to ActionScript and no vertical repositioning occurs. The clamp is still active for horizontal split and quadrant mode where it is needed.

Chat (UIComponent_Chat::render) / Tooltips (UIComponent_Tooltips::render): Removed the ComputeSplitContentOffset call entirely — the SWF content is already positioned correctly by the tile crop, so no additional offset is needed. Applied the same vertical-split scale-down fix as the HUD.

Related Issues

  • Fixes [https://discord.com/channels/1478227187843858563/1480314590637326499]

In vertical split at window heights below 1080, ComputeTileScale's min-scale clamp (>= 1.0) prevented the SWF from scaling down to fit, cropping the bottom and causing repositionHud to shift HUD elements downward. Chat and Tooltips additionally applied an offset from ComputeSplitContentOffset that only produced correct values at the 1920x1080 design resolution.

Override the scale for vertical split so the SWF fits the full window height when it is shorter than the movie. Remove the broken content offset from Chat and Tooltips -- the tile crop already positions the content correctly.
@MrTheShy
Copy link
Contributor Author

MrTheShy commented Mar 9, 2026

@codeHusky i am also fixing gamma so wait a second

The gamma shader sampled the full backbuffer texture (UV 0..1) into each player's viewport, stretching the entire screen into every split region. Extended the shader constant buffer with per-viewport UV offset and scale so each pass samples only its own portion of the backbuffer.

ComputeViewportForPlayer was hardcoded to top/bottom for 2 players, ignoring the vertical split setting. Rewrote it to read each player's m_iScreenSection directly, which already accounts for the split orientation preference.

Secondary players have no Graphics menu and cannot change gamma. CachePlayerGammas now reads the primary player's setting and applies it uniformly to all viewports.
@codeHusky codeHusky merged commit e2adaa0 into smartcmd:main Mar 9, 2026
1 check passed
Skullworks-Dev-Group pushed a commit to Skullworks-Dev-Group/MinecraftConsoles that referenced this pull request Mar 9, 2026
piebotc pushed a commit to piebotc/LegacyEvolved that referenced this pull request Mar 9, 2026
* Fix split-screen UI wrong positioning on window resize

In vertical split at window heights below 1080, ComputeTileScale's min-scale clamp (>= 1.0) prevented the SWF from scaling down to fit, cropping the bottom and causing repositionHud to shift HUD elements downward. Chat and Tooltips additionally applied an offset from ComputeSplitContentOffset that only produced correct values at the 1920x1080 design resolution.

Override the scale for vertical split so the SWF fits the full window height when it is shorter than the movie. Remove the broken content offset from Chat and Tooltips -- the tile crop already positions the content correctly.

* Fix gamma post-process in split-screen

The gamma shader sampled the full backbuffer texture (UV 0..1) into each player's viewport, stretching the entire screen into every split region. Extended the shader constant buffer with per-viewport UV offset and scale so each pass samples only its own portion of the backbuffer.

ComputeViewportForPlayer was hardcoded to top/bottom for 2 players, ignoring the vertical split setting. Rewrote it to read each player's m_iScreenSection directly, which already accounts for the split orientation preference.

Secondary players have no Graphics menu and cannot change gamma. CachePlayerGammas now reads the primary player's setting and applies it uniformly to all viewports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants