bugfix(water): Fix river borders appearing darkened under shroud #2592
bugfix(water): Fix river borders appearing darkened under shroud #2592afc-afc0 wants to merge 3 commits intoTheSuperHackers:mainfrom
Conversation
The river shroud was applied as a separate multiplicative pass on the framebuffer, which double-darkened terrain showing through transparent river edges. Apply shroud per-vertex in the diffuse color instead, so only the water contribution is shrouded before alpha blending.
|
| Filename | Overview |
|---|---|
| Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp | Adds per-vertex shroud modulation for river water and removes the old multiplicative shroud draw pass; logic and colour-channel ordering are correct. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[drawRiverWater called] --> B[Compute shadeR/G/B and diffuse from lighting]
B --> C{TheTerrainRenderObject not null?}
C -->|Yes| D[shroud = getShroud]
C -->|No| E[shroud = nullptr]
D --> F[Build dynamic vertex buffer per frame]
E --> F
F --> G[For each river vertex]
G --> H[getRiverVertexDiffuse]
H --> I{shroud not null?}
I -->|No| J[return original diffuse]
I -->|Yes| K[cellX = worldX / cellWidth]
K --> L[getShroudLevel returns 0-255]
L --> M[shroudScale = level / 255.0f]
M --> N[GameMakeColor with scaled RGB and original alpha]
N --> O[vb-diffuse = modulated colour]
J --> O
O --> P{More vertices?}
P -->|Yes| G
P -->|No| Q[Single draw call for river triangles]
Q --> R[Second multiplicative shroud pass REMOVED]
Reviews (3): Last reviewed commit: "Address PR Review" | Re-trigger Greptile
|
Did a little pre- post comparison, the results are interesting, this is using the map Winding River: 2026-04-13.00-23-21.mp4You can try by adding this commit: |
Fixes #2364
Description River borders appear darkened when under shroud, creating visual artifacts that force map makers to place rocks and other objects to hide them.
Root Cause
River water rendering in
drawRiverWater()applies the shroud as a separate multiplicative pass on the framebuffer after thewater is already alpha-blended onto the terrain. This causes double-darkening at transparent river edges:
pixel = terrain × shroudpixel = α × water + (1-α) × terrain × shroudpixel = shroud × (α × water + (1-α) × terrain × shroud)The terrain contribution at river borders becomes
terrain × shroud²instead ofterrain × shroud— visibly darker thansurrounding terrain. This is only noticeable under shroud (when
shroud < 1.0), since1.0² = 1.0.Note: Trapezoid water (lakes/ponds) avoids this by applying shroud in texture stage 3 of the main pass when pixel shaders are
available. River water cannot do this because stage 3 is already used for the river alpha edge texture.
Fix
Applies shroud per-vertex by looking up the shroud level at each river vertex's world position and multiplying it into the vertex
diffuse color before alpha blending. This ensures only the water's color contribution is shroud-modulated:
pixel = α × (water × shroud) + (1-α) × (terrain × shroud) = shroud × (α × water + (1-α) × terrain)The separate multiplicative shroud pass is removed, which also eliminates one draw call per river.
Testing
Tested with the minimal reproduction map (
Ariver.zipfrom #2364) — river borders no longer show dark outlines under shroud.