World Position Offset casts shadow on self (using Distance Fields)

I am making a slime-like material that uses World Position Offset and DistanceToNearestSurface to make meshes move towards near objects to act like slimes.
To make the material detect nearby objects I initially scale it so it makes a “detection zone” that I use to move the vertices to nearby objects if there are any.


the last multiply is plugged into WPO ^


Left = scale 25, 25, 0 / Right = scale 0, 0, 0

My problem is that the shadow that is being cast by the mesh is calculated using the detection zone instead of where the verticies actually are.

I made this material by following this tutorial and I saw that at 0:05 they actually managed to fix this issue but I’m not sure how since it isn’t what the video is about.
I’m thinking maybe by making the material be masked and using a shadow pass switch there might be a way to change the way the shadow is calculated and make it match where the vertices actually are but I can’t figure out the math behind it.

I asked for help in the comments of the tutorial I mentioned and got a reply from the guy who made the video !

Here’s how I “fixed” it :

It’s still not perfect, the shadow doesn’t squish with the slime and is always at the smallest size of the slime but at least now it’s not covering itself.

Still open to any potential solutions that might help with that.