Hey,
We are in process of upgrading project from UE4 to UE 5.6 and we’ve spotted some issues with our Water Material and Rivers. Our water Material uses WaterBodyData node -> Water Depth output to calculate WPO and simulate waves. While using this node I’ve spotted a bug: Water Depth on CPU does not match Water Depth on GPU. Based on this question [Content removed] I’ve done some debugging.
CPU value looks quite correct: I’ve put a relevant size box into water, and real water depth at that point is 22 meters, while GPU reports 44 meters.
[Image Removed]
While further debugging where GPU Water Depth value comes from, I’ve spotted, that it’s calculated based on Ground Z value.
While debugging that value in different places of the river, it clearly seems, that instead of real Ground Z, the Minimum Ground Z is returned (-3384 is the min extent of Landscape actor)
[Image Removed]
After further debugging, it seems that WaterInfoSample.w (used in DecodeWaterInfoGroundHeight function) is always zero. WaterInfoTexture contains correct Water Z data (blue channel), but apparently no (or not correct) ground Z data (alpha channel is completely black).
[Image Removed]
Underwater this place looks like that (Cube is placed at Z=-3384, so way below the real landscape):
[Image Removed]
Based on that Water Depth on GPU seems to be calculated wrong (Water Depth = Water Z - Ground Z, if Ground Z = always Min Ground Z result is wrong).
Do you have any ideas what is wrong with the setup? Maybe Landscape is missing some flag to be captured in properly? (“Auto Include Landscapes as Terrain” is set to true in WaterZone actor). Appreciate any ideas.
p.s. I’ve not yet managed to setup proper clean Landscape + Water setup (ie. not upgraded from ue4), but I could set it up if needed.
[Attachment Removed]
Managed to setup default map with Landscape and default Water Body River. I set the depth of water on river to be 512 (so 5.12m)
Again, CPU reports correct depth, while GPU is completely off:
[Image Removed]Terrain Z Height reports constant value = -141.4
Scene setup:
[Image Removed]
[Attachment Removed]
Hi,
This looks incorrect indeed.
Would you be able to test this on a UE5.8 build and produce a test project that exhibits the issue? Does this happen with D3D11 (-d3d11 in the commandline args)? You can also try to set the CVar r.Water.WaterInfo.RenderMethod 1 and see if it fixes the issue after you reload the map (you can also force the water info texture to re-render with r.Water.WaterInfo.ForceUpdateWaterInfoNextFrames 1)
If you want to debug this yourself, you can enable the RenderDoc plugin, install Render Doc (https://renderdoc.org/builds), then run the editor with -attachrenderdoc in the commandline args. You can then set the CVar r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws 1 and finally force a render with r.Water.WaterInfo.ForceUpdateWaterInfoNextFrames 1. This should open a capture in Render Doc of all the rendering steps that produced to the water info texture. You can either investigate from there or send us the capture so we can have a look. Also, if the problem does occur with D3D11, that usually makes the RenderDoc analysis much easier.
Let us know how it goes,
Cheers,
[Attachment Removed]
Hello,
D3D11 mode and cvar WaterInfo.RenderMethod 1 have no effect.
I’ve made 2 RenderDoc captures: 5.6 and 5.8.
UE 5.6 has no info in WaterDepthTexture:
[Image Removed]So in 5.6 it seems that WaterInfoMerged Alpha is completely black
[Image Removed]I’ve spotted that format of WaterTextureDepth is different across versions (5.8 uses R32_FLOAT instead of R16G16B16A16_FLOAT), but doubt that is the issue.
Looking further I’ve spotted, that Landscape is not being rendered to Depth, and I assume that is the issue.
[Image Removed]
Attached UE5.6 project (can be opened in 5.8 as well). Sadly EPS does not allow me to attach RenderDoc captures (too big probably), I have captures of both versions, let me know if I shall upload them somewhere you prefer.
Best regards
p.s. tried to cherry-pick CL 42989778 by tim doerries in ue5-main branch, which changed rendering from DeviceDepth to SceneDepth, but this did not help
p.s.s. To note: 5.6 has PrePass DDM_NonMaskedOnly while 5.8 has PrePass DDM_AllOpaqueNoVelocity instead inside WaterInfoDepthPass.
[Attachment Removed]
Hi again,
I don’t see such a problem locally with a vanilla UE 5.6 with your test project :
[Image Removed]
Have you made any modification to the engine? Is it possible that the problem comes from this?
In your screenshot, at EID 52-60, (PrePass DDM_AllOpaqueNoVelocity), this is where the landscape components should be drawn. As you can see, in my own capture (at EID 40-511), all the landscape components are being rendered and you can inspect and check that each individual draw call draws a landscape component :
[Image Removed]
I presume that in your case, something must prevent this from happening. If you’re using render method 1, have a look at the list of ground components gathered in UpdateWaterInfoRendering2 (WaterInfoRendering.cpp). If you’re using render method 2, you can trace the same thing in UpdateWaterInfoRendering_CustomRenderPass. ComponentsToRenderInDepthPass is what you should look at. You should then be able to pull on that thread and see why the landscape fails to render.
Let me know how it goes (please note that Epic will close for 2 whole weeks for summer break so expect delays)
Cheers,
[Attachment Removed]
May I ask how you disabled landscape in prepass? Is this via a CVar or some custom engine modification?
There’s a penalty to running a full-blown pixel shader (especially on landscape, whose material is usually amongst the most complex ones, particularly on components using several target layers) in a case where you only want depth. I can understand how disabling the pre-pass might help on some platforms (depending on your game content) but in an offline render pass such as water info rendering, I do not think it will ever be desirable.
Depending on how you disabled the prepass (i.e. if the depth-only shader is still available at runtime), you might be able to find a way to have the water info pass use the depth-only shader while maintaining the main depth pre-pass off for landscape. That is what I would advise you to look into.
Cheers,
[Attachment Removed]
Hello,
Thanks for the update. I quickly checked the issue in 5.8 and, apparently, Gpu depth works as intended (e.g. within the precision error). Sadly we have no option to upgrade our current project to 5.8, we shall stick to 5.6.
[Image Removed]I have actually tried to debug the Water Info texture including the methods you’d mentioned. I cannot tell if rendered texture is correct: In UE4 alpha channel represented landscape heightmap, but in UE5.x Water Info Alpha channel looks like some packed/encoded data. I managed to see that Landscape height data in water info shader basically returns Landscape’s Min Z. On a test level alpha channel of Water Info RT is always black, on real level - has some white spots (presumably some other meshes).
I could assume that for some reason Landscape is not rendered correctly into Water Info texture, but I cannot prove it.
Maybe you know some bug/CL regarding Landscape not being rendered correctly into Water Info? I could cherry-pick CLs if needed. I might also provide a UE5.6 test project if needed. Let me know if you need 5.8 test project as well.
Best regards
[Attachment Removed]
Hello Jonathan,
Thanks for testing fresh 5.6 on your side. We started checking local changes in engine to spot the issue as you’ve suggested.
Finally we found that we had disabled Prepass for several systems including Landscape (that gave us some frame time on platforms like Switch2), and I did not know Landscape utilizes Prepass to be rendered in WaterInfo. We fixed the issue by letting Landscape be rendered in prepass, which fixed the aforementioned issue with Water depth GPU read.
The only thing I have in mind: should the Landscape be rendered in Prepass? Like it could be a regular draw call writing to depth without such “cheating”. Aside from that, question could be closed.
Thanks for the effort,
Best regards
[Attachment Removed]
Hey Jonathan,
We had prepass disabled via engine modification. Returned it back with some combination of booleans for view relevance (so Landscape now is an exception and being rendered to prepass. Will look into options you mentioned
Thanks!
[Attachment Removed]