Skip to content

refactor(ww3d2): Route the shroud overlay via Renderer - #3704

Open
bobtista wants to merge 19 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-shroud-overlay
Open

bobtista wants to merge 19 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-shroud-overlay

Conversation

@bobtista

@bobtista bobtista commented Nov 20, 2026 •

Copy link
Copy Markdown

Follow up for #2613
Merge after #3700

This change routes the shroud texture pass states through Renderer.

W3DShaderManager keeps the pass and picks the material, texture, shader and depth test itself. Renderer gains Set_Texture_Coord_Source, Set_Texture_Transform_Count and Set_Depth_Compare for the states it could not set before. The texture matrix is built from Renderer::Get_Transform.

Testing

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The change adds capability and rendering operations to Renderer and implements them in DX8Backend. Rendering paths across WW3D, game clients, and tools now use Renderer. The change also adds a checked-cast template and updates debug macro definitions in GameText.cpp.

Changes

Renderer interface migration

Layer / File(s) Summary
Renderer contract and DX8 implementation
Core/Libraries/Source/WWVegas/WW3D2/Renderer.h, Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp
Renderer declares capability queries, render-target operations, resource binding, drawing, depth comparison, and texture-transform operations. DX8Backend implements these operations and maps renderer values to DX8 constants.
Capability queries and texture transforms
Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp, Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp, Core/Libraries/Source/WWVegas/WW3D2/{statistics,dx8renderer,mapper,matpass,matrixmapper,meshmdl,texture,textureloader,ww3dformat,meshmatdesc}.cpp
Texture-format, compression, N-patch, and related capability checks now use Renderer queries. Texture mapper matrices and material-pass texture limits also use Renderer.
WW3D rendering paths
Core/Libraries/Source/WWVegas/WW3D2/*, Generals/Code/Libraries/Source/WWVegas/WW3D2/*, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/*
Object, mesh, sorting, decal, dazzle, and 2D rendering paths now use Renderer for resource setup and drawing. Existing draw arguments and sorting paths remain in place.
Core game rendering paths
Core/GameEngineDevice/Source/W3DDevice/GameClient/*, Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/*
Terrain, effects, water, and shader-manager paths now use Renderer for state setup, resource binding, drawing, and capability checks. Shroud projection transforms are built and applied through Renderer.
Generals and GeneralsMD rendering paths
Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/*, GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/*
Shadow, bridge, road, scene, UI, status-circle, and other rendering paths now use Renderer for rendering operations. Existing conditions and draw parameters remain unchanged.
WorldBuilder and editor rendering
Generals/Code/Tools/WorldBuilder/src/*, GeneralsMD/Code/Tools/WorldBuilder/src/*, Core/Tools/W3DView/ScreenCursor.cpp
WorldBuilder draw paths, object previews, and W3DView cursor rendering now use Renderer for state setup, resource binding, drawing, or render-target selection.

Utility and Autorun updates

Layer / File(s) Summary
Checked cast helper
Core/Libraries/Source/Lib/Include/Lib/BaseFunctions.h
The new check_cast<T, U> template casts a value and asserts that converting the result back to U reproduces the input.
Debug macro definitions
Core/Tools/Autorun/GameText.cpp
The file undefines existing DEBUG_LOG and DEBUG_ASSERTCRASH macros before defining DEBUG_LOG(x) as a no-op.

Estimated code review effort: 4 (Complex) | ~50 minutes

Change: Refactor

Possibly related PRs

Suggested reviewers: xezon, stephanmeesters, cryotherenegade

Merge Risk: Minimal · up to 58563

This refactor routes rendering calls through the Renderer interface without intended behavior changes. The author reports pixel-identical output in a replay, and review found no concrete regressions. Merge-readiness risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names a refactor that routes the shroud overlay through the Renderer layer in WW3D2. The change set is mostly a broad migration of DX8Wrapper calls to Renderer across many files. The shroud …
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.
Description check Passed The description is related to the changeset. It states that the shroud texture pass states are routed through Renderer, and it names the touched APIs: Set_Texture_Coord_Source, Set_Texture_Transform_C…
Full details: Title check

Explanation

The title names a refactor that routes the shroud overlay through the Renderer layer in WW3D2. The change set is mostly a broad migration of DX8Wrapper calls to Renderer across many files. The shroud overlay move is part of the PR objectives, but the summaries show that the change set covers far more than the shroud. The title therefore relates to a real part of the change, but it does not name the main point. This is a partial match, so the check passes.

Full details: Description check

Explanation

The description is related to the changeset. It states that the shroud texture pass states are routed through Renderer, and it names the touched APIs: Set_Texture_Coord_Source, Set_Texture_Transform_Count, Set_Depth_Compare, and Renderer::Get_Transform. The summary shows W3DShaderManager shroud changes and new Renderer methods that match these names. It also lists build and replay test results. The description is brief but specific enough to describe the change, so the check passes.

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 67795fa4-35a3-430c-a019-f0452fc39b1a
Commits

Reviewing files that changed from the base of the PR and between b18cd8e and 5856392.

Files selected for processing: 3

  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/Renderer.h

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

// Draws until End_Shroud_Overlay multiply the frame by the shroud at the drawn world position.
// Only pixels at the depth already in the depth buffer change.
static void Begin_Shroud_Overlay(const RenderShroudOverlay & overlay);
static void End_Shroud_Overlay();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why is this moved into the Renderer? Will the implementation always differ between renderer backends and there is no way it can be higher up? Why?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The backend hides the DX8 camera-space texture generation, texture transform and depth state. Another backend would do this in its shader instead. The shroud texture and map projection stay in W3DShaderManager. I renamed the interface to Begin_Projected_Overlay with RenderProjectedOverlay, so it is a general projected multiply pass and shroud is just the caller.

@stephanmeesters stephanmeesters Nov 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Would agree it needs to be higher up, or the function should be made more generic, like there are some specific choices in DX8Wrapper backend I would expect in GameEngineDevice and not in WW3D2:

Get_Preset(PRELIT_DIFFUSE)
Set_Texture(0, overlay.texture)
Set_Shader(_PresetMultiplicativeSpriteShader)
ZFUNC = EQUAL

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@xezon @stephanmeesters At first I only reworded the comment and renamed Begin_Shroud_Overlay to Begin_Projected_Overlay to make it sound more generic. After your comments I reworked it. Begin_Projected_Overlay is gone. The shroud pass is back in W3DShaderManager. It sets the material, texture, shader and depth test itself and builds the texture matrix from Renderer::Get_Transform. Renderer only gained generic calls for what it couldn't express yet - Set_Texture_Coord_Source, Set_Texture_Transform_Count and Set_Depth_Compare.

@bobtista
bobtista force-pushed the bobtista/refactor/route-shroud-overlay branch from 58d0787 to 50f9297 Compare November 22, 2026 14:24
@bobtista
bobtista marked this pull request as ready for review November 22, 2026 20:06
@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no actionable issues were found.

Summary

Routes drawing calls, texture support checks, and render-target changes through Renderer.

  • W3D rendering calls now pass through Renderer.

No actionable issues found. Review was based on source inspection; builds and replay tests were not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Game and tool drawing code"] --> B["Renderer"]
  C["W3DShaderManager: shroud pass"] --> B
  B --> D["DX8Backend"]
  D --> E["DX8Wrapper"]
  E --> F["Direct3D 8"]
Loading

Reviews (1) · Last reviewed commit: "refactor(ww3d2): Keep the shroud pass in..." · Reviewed by Greptile

@stephanmeesters stephanmeesters added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing Rendering Is Rendering related labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing Rendering Is Rendering related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants