Download

Water depth World Based

I’m stuck with this problem:
I have 2 materials : a water material and a sand material.
I’m trying to get the value of the water depth world based by the Z axis ( not camera based ).
I tried a lot of node like depthfade ,WorldPositionBehindTranslucency , pixel/scene depth , … that give me value like the green or the orange one but i’m looking for the black value.

What i got : (If the camera don’t see the sand under water the node don’t give the height value)
DepthFade.png
What i’m trying to do: (I want that even if the camera don’t see the sand under the water the node give the height value )
WIW.png

You can bake height map of the sand and read it from texture at water material.

Is there a way to make it dynamic ?

Draw sand meshes with ortho camera with SceneCapture2d. Last time I tested depth rendering it didn’t work with ortho projection so I would use special material for sand meshes and draw height to color target. This scene capture can follow the player so you only need to draw close by area.

Works in 4.25, doing it one of my levels

​DONE !
Thanks for your help !
Here is the result in my test world :

Forum3.png
https://forums.unrealengine.com/core/image/gif;base64
​​​

Quick recap:
I putted my sand mesh in the Scene Capture 2D BP, set Projection Type to Orthographic, adjusted the camera position and set the Texture target to a TextureRenderTarget
In my material I imported texture and remapped the value to get float values between 0 and 1 and I got the mask i needed.

Forum1.png
Forum2.png