Depth Transparency and Z-Buffer Problem

I’m trying to setup the foam/shore break with depth transparency of the water plane.
The first problem is that the foam spreads depending on the camera angle. For example sometimes it’s closer to the beach, sometimes it goes further away instead of being fixed.
Is there a way to solve this? I’ve seen people use those vector converters like Vector transform or something but I don’t know how to apply it.
Could that solve the problem or am I on a totally wrong path?

Second question is regarding a z-buffer problem, I guess.
Other objects with alpha underneath the water plane are rendered in front of the water plane eventhough they actually are located behind it. I think this has something to do with zbuffer. Is it possible to avoid this somehow?

For example, the fishes and corals are rendered on top and in the wrong order

Thanks in advance for any help!

its been this way forever and no one cares enough to fix it. alpha clip is really the only solution.

this might fix you problem if you set this on your fish and coral planes.

this assumes “use node” is off.

Thanks for the replies, eventhough not quite what I expected :confused:
Having to use alpha clip is a bummer as it takes depth out of the textures.

you can fake depth using a node setup like this ( the lower on the Z axis the darker it gets. )

looks like this when in use

water-transparent.blend (2.2 MB)

Thank you, but I already got that fake depth in place.
What I was trying to achieve is giving the water plane depth transparency to detect where it intersects with terrain and use that intersection information to apply a “foarm/shore break”.
It does work perfectly but unfortunately, other alpha objects are not rendered correctly if the whole water plane uses any kind of transparency…