Can Depth Fade be made to work only on Z Axis (height), rather than on camera distance?

Hey all, quick quesiton. Is it possible to make the depth fade node work based on the depth from the top of the water, rather than distance from the camera? I want the ability to display objects in the water just like depth fade is able to when plugged into the base color, but I want the color change to be based on Z axis height, so that you can see distant objects as well as close ones, rather than having them fade out when they get too distant. You can see what I am talking about in this image of the old spyro games:

Calculate worldposition behind translucency then use only z position of that and water surface.

That sounds like it would work… Any chance of knowing what that would look like as nodes? Math was never really my strong point (failed algebra 2 three times in high school).

Calculate Distance of WorldPosition ComponenMask B and WordlpositionBehindTralucency ComponenMask B. Use that result as you like.

Sorry for the bump but this only work for horizontal water plane. Any slope result in zero depth