Render Texture To Draw a Texture with a mask

I’m trying to achieve this result :

It’s all about filling part of a texture, and I had met two problems:
First is modifying a texture pixels alpha, which i achieved with texture.SetPixel but it was just too slow, that’s when I did it with a shader, who receives the mouse position and changes the alpha of the pixels around.

This leads us to the second problem, i can’t find a way to save the modified pixels alpha (The drawn parts).

here’s my current shader:

Shader "Custom/DrawPainting"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _MousePos ("MousePos", Vector) = (-1,-10,-1,-1)
        _Radius ("HoleRadius", Range(0.1,5)) = 2
    }

    SubShader
    {
        Tags
        {
            "Queue"="Transparent"
            "IgnoreProjector"="True"
            "RenderType"="Transparent"
        }

        CGPROGRAM
        #pragma surface surf Lambert  alpha:blend
        #pragma target 3.0
    
        sampler2D _MainTex; 
    
        float4 _MousePos;
        float _Radius;

        struct Input
        {
            float2 uv_MainTex;
            float3 worldPos;
        };

        void surf (Input IN, inout SurfaceOutput o)
        {         
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
        
            float dx = length(_MousePos.x-IN.worldPos.x);
            float dy = length(_MousePos.y-IN.worldPos.y);
            float dz = length(_MousePos.z-IN.worldPos.z);
            float alpha = (dx*dx+dy*dy+dz*dz) / _Radius;
            alpha = clamp(alpha,0,1);
            if(alpha == 1)
                alpha = 0;
                else
                alpha = 1;
        
            o.Albedo = c.rgb;
            o.Alpha = c.a * alpha;
        }
        ENDCG 
    }
}

I would be very grateful if anyone has any suggestions.

Found a solution after following this guide:
http://studio.openxcell.com/remove-dustfog-object-unity-swipe.html

All you need to do is, after implimenting the tutorial, modify the TextureMasking shader line 45 to:

return fixed4(main_color.r, main_color.g, main_color.b, main_color.a * ( mask_color.a));

If I understood I think they generated a render texture, depending on the spray texture and mouse position, then pass the render texture as an alpha mask to the shader who will draw the hidden texture.

All the modified pixels are saved as a render texture, it’s fast (constant dps compared to SetPixel method) and practical, you can modify the spray texture to have the effect needed.