Water Refraction Shader Issue

Hello, I have a problem with water refraction. It refracts everything, even the objects above the water. I know why this is happening, but I can’t find a way to solve this problem. I tried to check if a fragment is under the surface, but still doesn’t work. I think the shader thinks that all objects are under the surface. If anyone knows a fix, a tip, or whatever I will be happy to hear it because I am very very stuck. Thank you! :))

P.S. I am writing a surface shader and not using shader graph

you need to compare the depths of the water surface and the depth buffer.

this tutorial goes through the basic principles.
Looking Through Water