_MainTex is a high-resolution texture that’s read-only, while _alphaTex is a low-res
texture that’s frequently updated with SetPixels()/Apply().
After updating from my custom 2D-system where I used texture2D to the new Sprite-class,
the SpriteRenderer won’t accept this shader since it’s fixed function.
I’ve spent time searching for a solution to this, but no luck so far.
Surely there’s some simple way to update this code for surface or cg?
So I don’t normally code things for people, on principle, but this seemed like the easiest way to explain it. And it’s mostly copy pasted from unity docs. I just tweaked it to serve your purpose.
(I also didn’t test it so I’ll leave the bugs to you )
I made it a transparent shader by
placing it in the right queue and
setting the correct blend mode.
I added 2 textures as input.
I use the same uvs for both.
I read in main tex.
Then I read in alphatex and set the
alpha based on my alphatex’s alpha.
This works for me except for one strange issue. The edges of the sprite are being “repeat stretched”. Have no idea what could be doing this. I do have many sprites near each other.