Skip to content

refactor(ww3d2): Route lights and fog via IRenderBackend - #3420

Draft
bobtista wants to merge 4 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-lights-fog
Draft

bobtista wants to merge 4 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-lights-fog

Conversation

@bobtista

@bobtista bobtista commented Oct 4, 2026 •

Copy link
Copy Markdown

Lights and fog are set through DX8Wrapper, and lights are turned off by passing a null D3DLIGHT8 pointer.

Now IRenderBackend has Set_Light, Clear_Light and Set_Fog, and the remaining Set_Light_Environment callers use the existing method. Clear_Light replaces the null D3DLIGHT8 call. ShaderClass::Apply still reads the fog color from DX8Wrapper, because it only uses it to set D3D render state.

Todo:

  • Build win32, including W3DView and WorldBuilder
  • Load two skirmish saves and the shell map, open W3DView through its device dialog, and open WorldBuilder. Same result as main
  • Water scene
  • Replicate to Generals

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46f5bea7-f5cb-4bfa-beac-ee4b1f018b60
📥 Commits

Reviewing files that changed from the base of the PR and between f8ba7eb and 94b4238.

📒 Files selected for processing (44)
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDebugIcons.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.h
  • Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h
  • Core/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h
  • Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/line3d.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
  • Core/Tools/W3DView/GammaDialog.cpp
  • Core/Tools/W3DView/MainFrm.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DStatusCircle.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/decalmsh.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/linegrp.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/mapper.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/mesh.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/DrawObject.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.


Walkthrough

The PR expands IRenderBackend and implements the added methods in DX8Backend. WW3D, library renderers, game rendering paths, and tools route selected queries and render-state operations through the backend. Water rendering also scales river-vertex diffuse color by shroud level when shroud data exists.

Changes

Render Backend Migration

Layer / File(s) Summary
Backend contract and DX8 implementation
Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h, Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.{h,cpp}, Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h
IRenderBackend adds device, resolution, transform, lighting, and fog operations. DX8Backend implements these operations through DX8Wrapper.
WW3D queries and camera setup
Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp
WW3D routes device and display queries through the backend. Camera and scene code use backend operations for viewport, transforms, fog, clears, and lights.
WW3D renderer state operations
Core/Libraries/Source/WWVegas/WW3D2/{dx8renderer,dynamesh,line3d,pointgr,ringobj,seglinerenderer,sortingrenderer,sphereobj,streakRender}.cpp, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/{boxrobj,dazzle,decalmsh,linegrp,mapper,mesh,render2d}.cpp
Renderer classes route selected transform, viewport, and lighting operations through the backend. Existing draw operations and rendering flows remain in place.
Game and tool rendering callers
Core/GameEngineDevice/Source/W3DDevice/GameClient/*.cpp, Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/*.cpp, GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/*.cpp, GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/*.cpp, Core/Tools/W3DView/{GammaDialog,MainFrm}.cpp, GeneralsMD/Code/Tools/WorldBuilder/src/DrawObject.cpp
Game callers route selected rendering operations through the backend. W3DView applies gamma through WW3D, and WorldBuilder routes object transforms through the backend. River vertex diffuse color is scaled by shroud level when shroud data exists.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Suggested reviewers: xezon

Merge Risk: ⚪ Minimal · up to 94b42

No actionable merge-blocking issue was established in the reviewed change. The planned rendering smoke test remains useful before release.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 94b42

The shared rendering interface changes, but inspected operations preserve existing rendering behavior and authority. No new security boundary crossing was established. Compatibility and lifecycle coverage remain incomplete, so the assessment is low risk rather than minimal.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated effects remain within shared rendering state and the local graphics device. The inspected migration establishes no new cross-process, tenant, or data-store reachability; this is a bounded conclusion, not a complete assessment of asset-controlled rendering inputs.

Trust Boundaries and Controls

  • inferred — The expanded API is an in-process abstraction boundary, not an evidenced authentication or authorization boundary. Inspected callers already controlled the corresponding wrapper operations, and forwarding does not establish greater authority over another security domain.

Resilience and Maintainability Implications

  • observed — Backend creation and conditional cleanup are unchanged in the target-branch comparison. Lite initialization skips D3D allocation. Existing non-lite partial-failure paths can return after loading the library without immediate cleanup; no newly reachable failure path was established by this routing change.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: routing light and fog operations through IRenderBackend.
Description check ✅ Passed The description explains the light and fog backend changes and related validation status.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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