bugfix(water): Fix river visuals in black shroud#2749
Conversation
|
| 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
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
|
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. |
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:
After:
