cut a hole in a sprite with alpha

I’m trying to cut a hole in a sprite using shaders. So far it works with the stencil shader, and some freely accessible code all over the web, however I’ve realised I can’t have transparent gradient edges on the hole. Here is what I can do currently:

but what I would like is to have transparent edges like this:

I’ve been trying for hours, but no luck so far. I’m sure there must be a way to do it. If someone could at least point me in the right direction I’d greatly appreciate it.

I’m not sure how you are trying to accomplish this, but;
The way i would go about it would be to create a new temp sprite and copy over the RGB data from the sprite you want cut from.

I would then define the area i wanted to cut, maybe based on the size of my cut-mask.
then go through each pixel of the defined area on the temp sprite and compare the alpha value to the corresponding pixel in the mask.

If the temp sprites pixels alpha value is higher than that of the corresponding pixel in the mask, then set it to the masks alpha value. repeat until all pixels are accounted for.

Then overwrite or replace the old sprite with the temp sprite.

You’re using shaders for transparency? I would just use unity’s built in Alpha From Grayscale option and Alpha Is Transparent option, both found when clicking on a Sprite in the project tab.