Impossible to create translucent non-planar water in UE4?

My ocean material has an opacity of 1 everywhere, but requires the depth-fade node for visual effects.
As a workaround i changed it’s blend mode to ‘translucent’ while setting the opacity to a constant of ‘1’.

The material also uses a Gerstner Wave Calculation as a vertex offset to simulate waves.

Everything looks good until the camera is placed as if the player swims inside the ocean, showing
that the engine can’t handle a 100% opaque material and the translucent-depth fails (see images).

http://i.imgur.com/oSuYDz0.png

http://i.imgur.com/rcYHZTE.png

So, how am i supposed to create an ocean that can use the depth-fade and render waves with vertex offsets?
That is one of the most basic things needed for a game, i am sure there is a workaround, right?

Hello StreakyCat,

I think you might have contrasting ideas here. To use an translucent depth fade, your material needs to be translucent and not opaque. You can fake the depth fade by lerping between two colors for shallow and deep water.

If you would like the simplest answer, then you can go into the Learn tab on the Launcher and download the ‘Water Planes’ which are free to use and add this to your project.

Let me know if you have questions.

Thanks,

I think you missunderstood my problem, so i will explain my point a little bit further:

I want a stylized water that is 100% opaque everywhere and uses dynamic vertice offsets to generate a realistic wave look.

Now, to create an even more stylized look, i need to create an outline of objects intersecting inside the water, which requires the depth-fade node, only available to PP or translucent materials.

So, i set the material to translucent and am now able to use the depthfade node to colorlerp my stylized outline for e.g floating objects.
What happens now is that the depth-check for the entire ocean mesh fails to apply on himself: polygons in the back are rendered above polygons in the frons, even though the material is 100% opaque.

I quickly setup a demonstration material for you:

http://i.imgur.com/ZdbemzI.png

Here is the outline for the intersecting object (as intended):

http://i.imgur.com/zlKJT8s.png

And here is the issue with the not-culled polygons rendered above fron-polygons:

http://i.imgur.com/0BeaLPl.png

The camera is below the wave, but all faces are rendered through the wave.Everything that is red lays behind the wave and should not be rendered, they should be culled since the translucent material is set to be 100% opaque.

I am going to recommend you take a look at the examples I mentioned in the Learn Tab, which will explain this process in a more visual way. Your opacity needs to be connected to a depth fade which also needs to be set to a specific value.

Please take a look at the examples I mentioned, as I am sure you will find the answer you are looking for within. It will also give you some more insight as to how to improve the quality of your shader.

Thank you,

You still don’t got my point and your recommended content examples did, as expected, not relate to the issue or help me out.

This is the exact problem:
Translucent Polygons of the same mesh are not ordered by distance, they are randomly drawn ontop of each other as the GPU renders them.
The reason for that seems to be that UE4 does not render translucent meshes to the depth buffer.

http://i.imgur.com/ErnMfwa.png

Therefore, it seems impossible to create a water surface with vertex based waves that uses translucency in UE4.
I found another user explaining the issue with the following video:
[- YouTube][2]

Related Forum entry:
[Translucent Water Material - Displacement Banding Issue - Rendering - Unreal Engine Forums][3]

The BeeJ seemed to have found a workaround which i didn’t test yet.
Sadly, it doubles the vertice count (and vertex offset calculations) and therefore is a heavy drawback in performance for large ocean areas :confused:

This is coming down to Forward Rendering versus Deferred Rendering. If you would like, the owner of that forum post (DotCam) as well as other users have created an open source Ocean Shader which is probably the best known solution in place currently.

Ocean Water Shader [WIP]

When it comes to sorting objects with translucent materials, you can set their translucent sort priority so they render at the correct depth, and sort either in front or behind other objects based on their numerical value.

This is coming down to Forward Rendering versus Deferred Rendering. If you would like, the owner of that forum post (DotCam) as well as other users have created an open source Ocean Shader which is probably the best known solution in place currently.

I already have a custom ocean shader, but thanks

When it comes to sorting objects with translucent materials, you can set their translucent sort priority so they render at the correct depth, and sort either in front or behind other objects based on their numerical value.
Well, i know. But that does not work in this case since the water and it’s waves belong to the same actor / mesh.