Subnautica water shaders and effects

How does Subnautica do these specific effects on underwater transitions on the player camera and submarine glass?
The following images are examples and a comparison between fog on and off.



Probaly some form of a fragment shader that does a form of sample of the screen or of the water height from some script or possibly a water shader. Hard to say though since i dont have alot of experience with shaders. Although it seems one solution would be to sample the vertex height at screen space and apply the fog if under that point on the screen. Although this would be choppy since vertexes arent that many ussualy so maybe do some interpolation for it aswell. (This is a more generalized answer and not really unity specific since i belive it should be simmilar)

Thanks for the reply! I don’t know much about shaders and was trying to do something similar using Shader Graph in Unity, but honestly I have no idea how to implement what you mentioned (sampling height on the screen and applying fog below a certain point). Do you have any practical example or maybe images that show something similar? I think seeing a visual example would really help me understand it better.

I dont have a specific image but if youre using shader graph. What i would do is i would get the vertex height and convert that to a screen coordinate or a screen position. then just check if a pixel is below or above that and just apply some blue fog or color/tint to it. although this might result in some areas between the verticies where it isnt lining up with the water. For that i would use just the float or height map for the water in the shader instead from the water shader/calculation. Then the fog and water is probaly just some simple fog with a tint. If youre wondering about the vertex to screen space thing you can probaly just google it and find how to do it.