Generating a dynamic alpha mask texture in code

Hi, so I have only a small experience level with shaders in any language, and none in Unity. What I am trying to do is turn a 2D array (of booleans or floats) into the Alpha Mask Texture for a shader that already uses a static alpha mask.

Here is the high level overview of what I’m trying to do: programmatically create a Alpha Mask Texture that will change over time (as the user touches the texture, it modifies the alpha in that area), and apply that alpha mask that sprites shader.

So here’s where I am now: I have my 2D array of booleans with the same width and height as my texture.
I think I can do something like this to set the alpha mask dynamically:

mySprite.renderer.material.SetTexture(“_AlphaTex”, myAlphaRenderTexture);

but I need help creating the RenderTexture myAlphaRenderTexture object…Some but not all of the pixels in this texture will be modified every frame, so I’d like the texture to persist and easily and arbitrarily access any pixel in the texture, and I don’t want to have to recreate the texture each time I want to change the mask.

you won’t have to recreate the texture that you keep uploading to - see SetPixels() and Apply()… but nevertheless the whole texture still has to be uploaded to the graphics card every frame. Slow.

I don’t see a SetPixels function on RenderTexture. Could you step me through creating the RenderTexture object, changing an arbitrary pixel, and then setting it to the material?

Also, you mentioned uploading the texture to the graphics card every frame will be slow. Do you have a suggestion for an alternate method of achieving my requirements that would have better performance? I am not committed to doing it this way especially since great performance is a requirement of my project.