Hey everyone,
Finally managed to solve this with the help of a friend! Here are the nodes for getting the distance foam to wrap around objects that intersect the water surface, and scroll in the desired direction.
This will give you something like this, but animated of course, since this is just a screenshot.
The texture I used is just a simple stepped gradient with some colors. Here it is for anyone who wants to use it when trying this out.
To get rid of the visible seam caused by the UV distortion you have to adjust your MipValueMode.
You can then plug the resulting UV coordinates and the mask into your own foam setup. Here is a peak at my own foam: