Skip to content

bugfix(water): Fix river visuals in black shroud#2749

Open
stephanmeesters wants to merge 2 commits into
TheSuperHackers:mainfrom
stephanmeesters:bugfix/river-black-shroud
Open

bugfix(water): Fix river visuals in black shroud#2749
stephanmeesters wants to merge 2 commits into
TheSuperHackers:mainfrom
stephanmeesters:bugfix/river-black-shroud

Conversation

@stephanmeesters
Copy link
Copy Markdown

@stephanmeesters stephanmeesters commented May 27, 2026

The problem was that the opacity of the river visuals ("sparkles") did not get scaled by the shroud level. To apply this alpha scaling only to the sparkles a change to the river shader was made.

Observe that the sparkles are now also less bright inside the fog.

Before:

Screenshot From 2026-05-27 20-50-49

After:
Screenshot From 2026-05-27 22-46-22

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 27, 2026

Greptile Summary

This PR fixes river visual highlights (sparkles and edge alpha) being rendered at full brightness inside fog/shroud by propagating the shroud scale through both the CPU-side vertex colour computation and the GPU-side ps.1.1 pixel shader.

  • In getRiverVertexDiffuse, the vertex alpha (previously left unscaled) now multiplies by shroudScale, so the alpha packed into the diffuse colour reflects the shroud level consistently with the RGB channels.
  • In the m_riverWaterPixelShader pixel shader, the base water RGB multiply is split from the alpha write (mul r0.rgb + mov r0.a), and the highlight registers r1 (sparkles × noise + edge alpha) are scaled by v0.a via mul r1.rgb, r1, v0.a before being added to the base water, ensuring river highlights dim inside the shroud.

Confidence Score: 5/5

Safe to merge; changes are isolated to river water rendering and correctly fix shroud-level propagation without touching any game logic or data paths.

The CPU fix (getRiverVertexDiffuse alpha scaling) and the GPU fix (ps.1.1 highlight scaling via v0.a) are both straightforward and directly address the stated visual regression. No game state, data structures, or other rendering paths are affected.

No files require special attention.

Important Files Changed

Filename Overview
Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp Two-part fix: (1) getRiverVertexDiffuse now scales the vertex alpha by shroudScale (matching RGB channel treatment), and (2) the ps.1.1 river water pixel shader separates RGB/alpha multiplication so river highlights (sparkles + edge alpha) are multiplied by v0.a (the shroud-scaled vertex alpha) before being composited onto the base water. Logic is correct; one minor inconsistency: the alpha argument to GameMakeColor lacks the (Int) cast used by all three RGB arguments.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["getRiverVertexDiffuse()"] --> B["shroudScale = level / 255.0f"]
    B --> C["GameMakeColor(R*shroud, G*shroud, B*shroud, A*shroud)"]
    C --> D["Vertex diffuse written to river mesh"]
    D --> E["ps.1.1 Pixel Shader"]
    E --> F["mul r0.rgb, v0, t0\n(base river x vertex RGB)"]
    E --> G["mov r0.a, t0\n(keep river texture alpha)"]
    E --> H["mul r1, t1, t2\n(sparkles x noise)"]
    H --> I["add r1.rgb, r1, t3\n(+ edge alpha)"]
    I --> J["mul r1.rgb, r1, v0.a\n(scale highlights by shroud alpha)"]
    F --> K["add r0.rgb, r0, r1\n(composite final river colour)"]
    J --> K
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp:182
The alpha argument is missing the explicit `(Int)` cast that all three RGB arguments use. All other arguments cast the `Real` multiplication result to `Int` before the implicit narrowing to `UnsignedByte`, which is the standard pattern here and avoids `-Wconversion` warnings. Leaving the alpha channel without the cast is inconsistent and may produce a compiler diagnostic.

```suggestion
		(Int)(((diffuse >> 24) & 0xff) * shroudScale));
```

Reviews (2): Last reviewed commit: "Adjust river water shader" | Re-trigger Greptile

@xezon
Copy link
Copy Markdown

xezon commented May 27, 2026

The second image looks strange, almost as if the water is gone. The blue color is missing from the water.

@stephanmeesters
Copy link
Copy Markdown
Author

The second image looks strange, almost as if the water is gone. The blue color is missing from the water.

Fixed. The alpha affected the base water instead of only the sparkles.

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.

River visuals are visible in black shroud

2 participants