Is this possible

How you made it waving? mine stays as a simple line

is relevant:
https://en.wikipedia.org/wiki/Underw…t_diagram3.jpg

The same article states the visibility distance in clear ocean water is 74m.

Using Arnage’s method, has anyone tried to implement underwater refraction for the water surface? I am using an inverted plane from my water surface with refraction enabled so that I can get refraction when underwater and looking up at the world outside of my water body. But it seems that the distortion is not being applied properly and not taking the PP fog into account. I’ve been trying to solve for days now but to no avail.

Here’s what I am expecting the distortion to look like when underwater (combined with the fog PP effect ideally, but it’s not enabled in screenshot):

And here’s what it looks like with the PP enabled:

Any input or pointer would be greatly appreciated.

Thank,

The fog calculation is based on an undistorted depth buffer, which causes the artifacts you’re noticing. You could fix by also distorting the depth buffer for the fog calculation, but there is another going on that I would recommend fixing instead:

The fog extends above the water plane, as the solution described earlier doesn’t handle looking back up like you are doing completely correct. Often can be ignored, but in case it just looks wrong. To fix you should calculated the fog based on the distance up to, but not beyond, the water plane. If your water plane is flat can be easily calculated inside the shader. If it isn’t totally flat (for example due to waves) you need a more complex solution. For example, you could render the water plane to the custom depth buffer and then take the minimum of the regular and custom depth buffers as the distance to base the fog calculation on.

Thanks a lot for your quick reply Arnage. I was able to fix it by not calculating the fog beyond the water plane, which is indeed flat in my case. Thanks!

works well so far, but how did you achieve the wavy look of the line? Your preview shows , but setting the scalar parameter to 0 for a water plane at Z = 0 gives me a perfectly straight gradient. I tried putting in a sine, but that would animate the whole line up and down instead of actually rendering the sine as a water line.