How to mofdifying depth mask at runtime

Hi everyone and sorry in advance for my bad english, so ill try be clear and understandable.

Im currently working on a “2d point&click” framework.
I try to implement a “walk behind” feature, as Ags does.
The goal is to avoid the need to split a sprite into Z arrangment pieces, into a more user friendly mask painting system (the best would be a custom component that hold a closed spline, witch is used to draw the depth mask… but one step at a time).

I think the best aproach would be to use depthMasking on some area of the sprite.
And adjust pawn’s depth grayscale at runtime, depending his position (i use a box that return pawn’s foots Y pos). I am correct? And if not, what would be the proper way to achieve this?