Skip to content

fix: Render entire terrain on GeneralsOnline extended zoom (water plane bleeds through on large maps)#513

Closed
sailro wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
sailro:fix/draw-entire-terrain-water-plane
Closed

fix: Render entire terrain on GeneralsOnline extended zoom (water plane bleeds through on large maps)#513
sailro wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
sailro:fix/draw-entire-terrain-water-plane

Conversation

@sailro

@sailro sailro commented Jun 12, 2026

Copy link
Copy Markdown

Summary

On GeneralsOnline builds, larger maps render as mostly water when the camera is zoomed out, even on maps that contain no water at all. Only a fixed-size window of terrain around the camera focus is drawn; everything beyond it falls back to the global water plane. This reproduces on a stock install with no INI modifications.

Repro

  • Stock GeneralsOnline 60 Hz client (GENERALS_ONLINE_VERSION_STRING "060526_QFE2").
  • Load a large map and zoom the camera out toward maximum.

Result on a stock / vanilla INI install - terrain beyond the draw window is not rendered and the global water plane shows through:

Vanilla install, zoomed out: terrain window surrounded by water

The smaller the draw window, the worse it is. With StretchTerrain = Yes (a 65-tile window) it collapses to a tiny island:

StretchTerrain shrinks the window further

Root cause

m_drawEntireTerrain decides whether the whole heightmap is drawn or only a fixed window centered on the camera:

  • WorldHeightMap.cpp:475 - default window NORMAL_DRAW_WIDTH = 1 + 4*VERTEX_BUFFER_TILE_LENGTH = 129 tiles (VERTEX_BUFFER_TILE_LENGTH = 32, WorldHeightMap.h:45, :124).
  • WorldHeightMap.cpp:532-534 and createDrawArea (:2214-2217) - when m_drawEntireTerrain is set, the draw area is expanded to the full map (m_width / m_height).
  • W3DView.cpp:776 - the camera far-clip plane is aligned to the same size.

In retail this defaults to FALSE, and the only way to enable it was the DrawEntireTerrain GameData INI key. Retail's limited camera zoom never zoomed far enough to reveal the gap, so it was never visible.

GeneralsOnline adds non-retail extended camera zoom (lobby max_cam_height up to GENERALS_ONLINE_MAX_LOBBY_CAMERA_ZOOM = 1000). Commit 6694942 ("Temp fix for draw entire terrain") then added GENERALS_ONLINE_TEMP_FIX_DRAW_ENTIRE_TERRAIN, which:

  • removes the DrawEntireTerrain field from the INI parse table (GlobalData.cpp:97-99), and
  • leaves m_drawEntireTerrain at its FALSE default (GlobalData.cpp:835).

So at extended zoom the 129-tile window no longer fills the screen and the water plane fills the rest. Players cannot work around it either: the INI field no longer exists, and a loose INI override would change the INI CRC (sent to the service as ini_crc; a mismatch returns 417 Anticheat mismatch, OnlineServices_LobbyInterface.cpp:1188), so it is not viable for online play.

Proposed fix

Force m_drawEntireTerrain = TRUE under the macro. It stays out of the INI parse table, so the INI CRC is unchanged and every player remains consistent / retail-compatible, but the full map is rendered at any zoom.

#if defined(GENERALS_ONLINE_TEMP_FIX_DRAW_ENTIRE_TERRAIN)
    m_drawEntireTerrain = TRUE;
#else
    m_drawEntireTerrain = FALSE;
#endif

This is a client-side visual setting only - no effect on the simulation or the INI CRC.

@x64-dev - context and a question

You introduced GENERALS_ONLINE_TEMP_FIX_DRAW_ENTIRE_TERRAIN in 6694942 while fixing the metaevent merge (TheSuperHackers#2577). Since it is labelled a temp fix, could you confirm what it was guarding against?

  • If it was only to keep DrawEntireTerrain out of the INI/CRC for player consistency, then forcing it TRUE (above) preserves that and fixes the rendering.
  • If DrawEntireTerrain = TRUE itself caused a problem at 60 Hz / extended zoom (perf or a crash), then the better fix is to scale the terrain draw window to the camera frustum so only zoomed-out views pay the cost, instead of always drawing the whole map. Glad to take it in that direction with your input.

Tradeoffs

  • Drawing the entire terrain has a per-frame cost on very large maps (the same tradeoff retail players accepted with DrawEntireTerrain = Yes). A camera-scaled draw window would be the more refined fix; this PR is the minimal one.

Testing and disclosure

  • Repro confirmed on a live stock install (the vanilla screenshot above).
  • The change is a one-line value flip guarded by the existing macro (type-safe by inspection). I have not completed a full local engine build yet, and would value maintainer validation of perf/visuals on large maps.
  • Diagnosis and patch were produced with AI assistance (GitHub Copilot CLI) and reviewed by me, per CONTRIBUTING.md.

References

  • Regression: 6694942 ("Temp fix for draw entire terrain")
  • NextGenMP_defines.h:14; GlobalData.cpp:97-99, :835; WorldHeightMap.cpp:475, :532-534, :2214-2217; WorldHeightMap.h:45, :124; W3DView.cpp:776; OnlineServices_LobbyInterface.cpp:1188

…plane bleed-through

GENERALS_ONLINE_TEMP_FIX_DRAW_ENTIRE_TERRAIN removes the DrawEntireTerrain INI
field and leaves m_drawEntireTerrain at its FALSE default. Combined with
GeneralsOnline's non-retail extended camera zoom, the partial terrain draw
window no longer covers the visible area on large maps, so the global water
plane shows through and maps without water appear flooded.

Force m_drawEntireTerrain = TRUE under the macro so the full map renders at any
zoom. This is visual-only: it does not affect the simulation or the INI CRC, so
all players stay consistent/retail-compatible.

Regression introduced in 6694942 ("Temp fix for draw entire terrain").

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sailro

sailro commented Jun 12, 2026

Copy link
Copy Markdown
Author

Closing this.

The GeneralsOnline team (ibra) confirmed that disabling DrawEntireTerrain is intentional: forcing it on causes massive performance degradation, tracked upstream as TheSuperHackers#2743 (most likely from the recent heightmap changes in TheSuperHackers#2677).

I verified locally on a Win32 build with m_drawEntireTerrain = TRUE: the full terrain renders correctly, but it is "ultra slow" even at normal skirmish zoom, independent of camera height. So this PR's approach simply trades the water-plane artifact for the perf regression and is not the right fix.

The real fix belongs upstream (making full-terrain drawing performant again, TheSuperHackers#2743). Closing in favor of that. Thanks for the context, and apologies for the noise!

@sailro sailro closed this Jun 12, 2026
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.

1 participant