Need help creating a shader that masks hair under a helmet

Hey all,

I am trying to create a shader that will mask hair under a helmet. In masking approaches I have seen, shaders can mask a sprite based on a texture.

That is close to what I need, but I instead need to mask anything above or behind a sprite. In this case, I want to use the transparent area below/above a helmet sprite to mask the hair sprite behind it. Am I able to sample a sprite like that within a shader, to determine if there is nothing but alpha from this pixel upwards?

Here is a professional-quality image of what I mean. The green area is the hat, the dark-brown is some hair, and the pink is the masking area.

Thoughts? Any help is appreciated.

Here is another view, showing the hair underneath. It hopefully shows why it is a problem, since the hair sprite is actually larger than the helmet sprite.

you found a solution yet??