Skip to content

fix(view): Adjust default camera height to compensate for screen aspect ratio - #1711

Draft
Mauller wants to merge 1 commit into
TheSuperHackers:mainfrom
Mauller:fix-default-camera-height
Draft

fix(view): Adjust default camera height to compensate for screen aspect ratio#1711
Mauller wants to merge 1 commit into
TheSuperHackers:mainfrom
Mauller:fix-default-camera-height

Conversation

@Mauller

@Mauller Mauller commented Oct 18, 2025

Copy link
Copy Markdown

Merge with Rebase

This PR adjusts the default max camera height to compensate for different screen aspect ratios.

Previous work fixed the vertical field of view to match retail and adjusted the horizontal fields of view.
But this resulted in significant distortion being observed in the periphery of the view and lower corners.
This distortion was also observed at the 16:9 aspect ratio and became significantly worse as the aspect ratio increased.

By maintaining the original 60 degrees horizontal field of view, while allowing the game to narrow the vertical field of view, increasing the camera height results in minimal to no distortion being observed.

This PR does not fix any other known camera issues and focuses on giving a playable default view.


TODO

  • Implement in generals

@Mauller Mauller self-assigned this Oct 18, 2025
@Mauller Mauller added Bug Something is not working right, typically is user facing GUI For graphical user interface Major Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Oct 18, 2025
@Mauller Mauller added this to the Major bug fixes milestone Oct 18, 2025
@ElTioRata

Copy link
Copy Markdown

Comparison

Comment thread GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp Outdated
@xezon

xezon commented Oct 19, 2025

Copy link
Copy Markdown

At 4:3 "This Change" gives identical view to "Original Game + GenTool" ✅

At 16:9 "This Change" gives a bit more view than "Original Game + GenTool" ❓

Is this correct? I do not recall if GenTool view is correct.

zoom16x9

@xezon xezon added Enhancement Is new feature or request and removed GUI For graphical user interface labels Oct 19, 2025
@Mauller

Mauller commented Oct 19, 2025

Copy link
Copy Markdown
Author

At 4:3 "This Change" gives identical view to "Original Game + GenTool" ✅

At 16:9 "This Change" gives a bit more view than "Original Game + GenTool" ❓

Is this correct? I do not recall if GenTool view is correct.

zoom16x9

My goal was to try match the vertical view as close as possible to retail, I think it's slightly less than compared to 4:3 but slightly more than 16:9 gentool + retail.

I think it has a reasonable tradeoff considering the extended horizontal view.

It also gives a reasonable view for aspect ratios between 4:3 and 1:1 as well. Giving a little more vertical view.

Under 1:1 things are still quite broken but a lot needs changing in the view handling to properly support portrait mode.

@xezon

xezon commented Oct 19, 2025

Copy link
Copy Markdown

Yes GenTool did take some vertical view away to compensate for the wider view, perhaps in an attempt to keep conditions fair. Additional camera height does give a competitive advantage. Are we ok with giving advantages to Wide Screen?

@Mauller

Mauller commented Oct 19, 2025

Copy link
Copy Markdown
Author

I wouldn't consider it an issue since most screens have been wide aspect For the past decade. If anything widescreen is the standard now.

Ultrawide is where it becomes more of an issue. But we could look at implementing a locked aspect mode for the tactical view in future.
This could give a standardised view to all players in a competition etc.

Or another option could be implementing tactical zoom to let people zoom out to view the entire map etc.

@Mauller
Mauller force-pushed the fix-default-camera-height branch from 02a64e0 to 57fe78d Compare October 19, 2025 15:37

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple implementation, but man the EA code is confusing.

Comment thread GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
Comment thread GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
Comment thread GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
Comment thread GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp Outdated
@Mauller
Mauller force-pushed the fix-default-camera-height branch from 57fe78d to 271ca5b Compare October 19, 2025 19:09
@Mauller

Mauller commented Oct 19, 2025

Copy link
Copy Markdown
Author

Tweaked the code so setDefaultView is now setDefaultCameraHeight with a default argument of 1.0f for the heightScale.

Still need to look at the zoom default handling.

@Mauller
Mauller force-pushed the fix-default-camera-height branch from 271ca5b to f6c96d8 Compare October 19, 2025 19:36
@Mauller

Mauller commented Oct 19, 2025

Copy link
Copy Markdown
Author

Updated with tweaked max and default zoom handling code.

@Mauller
Mauller force-pushed the fix-default-camera-height branch from f6c96d8 to c3c7b85 Compare October 19, 2025 19:56
@Mauller

Mauller commented Oct 19, 2025

Copy link
Copy Markdown
Author

Small tweak to comments

@Mauller
Mauller force-pushed the fix-default-camera-height branch from f0dc49b to f5167b0 Compare April 6, 2026 13:20
@seacat17

seacat17 commented Apr 7, 2026

Copy link
Copy Markdown

How far are we from having this in the main build? I want to try all the new things...

@Mauller
Mauller force-pushed the fix-default-camera-height branch 3 times, most recently from 5617740 to a076193 Compare April 11, 2026 19:00
@Mauller
Mauller force-pushed the fix-default-camera-height branch from a076193 to 2523ec0 Compare April 20, 2026 15:46
@Mauller
Mauller force-pushed the fix-default-camera-height branch 2 times, most recently from bb8c588 to ec0c082 Compare May 4, 2026 09:15
@xezon

xezon commented May 6, 2026

Copy link
Copy Markdown

I think we can go ahead with this now. Can you rebase it?

@Mauller

Mauller commented May 6, 2026

Copy link
Copy Markdown
Author

I think we can go ahead with this now. Can you rebase it?

Sure, i will rebase and take a look back over the implementation to see if theres any tweaks i can make after your recent changes.

@Mauller
Mauller force-pushed the fix-default-camera-height branch from ec0c082 to baa303e Compare May 6, 2026 18:58
@Mauller

Mauller commented May 6, 2026

Copy link
Copy Markdown
Author

Just a raw rebase on current main of the original implementation, still need to look back over it, make any suggestions.

I think i can move a lot of what i seperated out back into setdefaultview now compared to when i originaly wrote this.

@Mauller
Mauller force-pushed the fix-default-camera-height branch from baa303e to 0813a5b Compare May 8, 2026 09:02
@xezon

xezon commented May 9, 2026

Copy link
Copy Markdown

The scripted camera is too high.

In my opinion the height difference compared to GenTool is too much - around 3.6% difference. Especially with Control Bar Pro it will give a significant bump is viewable terrain. For starters, I suggest to set it up exactly like GenTool did.

GenTool nerfs the height by this much: const float nerf = 1.0f - (aspect - aspect_4_3) / 12.0f;

Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
@droideveloper

Copy link
Copy Markdown

The scripted camera is too high.

In my opinion the height difference compared to GenTool is too much - around 3.6% difference. Especially with Control Bar Pro it will give a significant bump is viewable terrain. For starters, I suggest to set it up exactly like GenTool did.

GenTool nerfs the height by this much: const float nerf = 1.0f - (aspect - aspect_4_3) / 12.0f;

Does this have to be as is in GenTool implementation ? I believe no here is why

  • 3.6 % difference in calculation in between is I mean...really ? Does it matter no, why GenTool is not base
  • Why it was divided by 12, it is magic number calculating by dynamic aspect ratios 16:8 or 32:9 or 16:9 relative to 4:3 is way to go no ?

I have been waiting for too long but (since first implementation it was fine for me except units in the edge of map) still better than current state, why not fix it is as it is implemented than patch later better way if there is ?

@xezon

xezon commented Jun 4, 2026

Copy link
Copy Markdown

Does this have to be as is in GenTool implementation ?

The widescreen nerf was deliberate to reduce it a bit to make the advantage over 4:3 not as large. The game was originally made for 4:3 aspect ratios and is still played this way by many players. GenTool was the standard tool to use from 2010 to 2025, and still is for retailers.

@mirelle7

Copy link
Copy Markdown

Do we have actual data on how common 4:3 resolutions still are for our player base? For context, when 4:3 resolutions last appeared in the Steam Hardware Survey stats back in August 2023, they made up 0.0021% of users.

@xezon

xezon commented Jul 18, 2026

Copy link
Copy Markdown

I expect 16:9 are dominating but 4:3 is still a valid resolution to support because the original game UI was designed for 4:3.

@Mauller
Mauller force-pushed the fix-default-camera-height branch from 50d5e19 to 25691fe Compare July 26, 2026 12:49
@wolfetplayer

Copy link
Copy Markdown

Any update on this?

@Mauller
Mauller force-pushed the fix-default-camera-height branch from 25691fe to 23ae250 Compare August 21, 2026 16:35
@Mauller
Mauller force-pushed the fix-default-camera-height branch from 23ae250 to 51811c2 Compare August 29, 2026 09:03
@Mauller
Mauller marked this pull request as draft September 4, 2026 16:01

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep the Mauller busy

if (currentAspectRatio > baseAspectRatio)
{
aspectRatioScale = fabs((1.0f + (currentAspectRatio - baseAspectRatio)));
const float nerf = 1.0f - (currentAspectRatio - baseAspectRatio) / 12.0f;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can add comment here that this nerf replicates what GenTool originally did as well. The purpose was to artificially nerf the widescreen bonus a bit.


if (currentAspectRatio > baseAspectRatio)
{
aspectRatioScale = fabs((1.0f + (currentAspectRatio - baseAspectRatio)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fabsf

Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
{
// TheSuperHackers @fix Mauller 08/05/2026 Adjust the maximum camera height to compensate for screen aspect ratio
Real baseAspectRatio = (Real)DEFAULT_DISPLAY_WIDTH / (Real)DEFAULT_DISPLAY_HEIGHT;
Real currentAspectRatio = (Real)TheTacticalView->getWidth() / (Real)TheTacticalView->getHeight();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like us to implement a define to clamp the max aspect ratio scaling here and set that to 1.7777 for 16:9 in GameDefines.h

That is also what GenTool did. It is then up to the Game Design Committee to decide what the actual limit should be for multiplayer.


// MDC - we no longer want to rotate maps (design made all of them right to begin with)
// m_defaultAngle = angle * M_PI/180.0f;
setDefaultPitch(pitch);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest keep this line at the top of the function to have the things separated.

@@ -2233,10 +2233,24 @@ void W3DView::setPitchToDefault()
//-------------------------------------------------------------------------------------------------
void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxHeight is ambiguous name. Maybe rename to maxHeightScale. It reaches from 0 to 1 (or higher)

@@ -2233,10 +2233,24 @@ void W3DView::setPitchToDefault()
//-------------------------------------------------------------------------------------------------
void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we clamp maxHeight at above 0. It should not become negative.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For camera height in cinematics:

After #3003 is merged, there will be ScriptEngine::isLetterBoxActive to act on regular campaign cinematics. Is logic bound.

Otherwise there also is View::m_isUserControlled to check whether the user was the last one to control the camera. Is client bound.

m_heightAboveGround = m_maxHeightAboveGround;
m_zoom = getMaxZoom(m_pos.x, m_pos.y);

stopDoingScriptedCamera();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken right now all calls to stopDoingScriptedCamera in this file are as was originally. It would be nice if we can remove all these calls in this file except in W3DView::reset, but I am not sure if that is safe then. It depends on scripted calls I think. Maybe you can investigate this matter.

stopDoingScriptedCamera is already called extensively in View::doUserAction which we added and is verified to come through user input exclusively (good)!

@xezon xezon added Critical Severity: Minor < Major < Critical < Blocker and removed Major Severity: Minor < Major < Critical < Blocker labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Critical Severity: Minor < Major < Critical < Blocker Enhancement Is new feature or request Gen Relates to Generals ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Camera height does not scale properly along with aspect ratio of game resolution

9 participants