I am using URP 2D. Currently if I use UV node then it can make the sprite transparent like this image A. However, if I use my own texture, in the preview it looks like it’s suppose to but then in editor or during runtime, it doesn’t work, like in image B. How do I use my own texture as the alpha for any sprite?
This setup works for me, make sure the transparent texture you are feeding has the proper R value, because it is the one setting the alpha in your second shader graph. If you want to use the alpha channel of the transparency texture, feed in the A channel instead.
feeding A channel will do nothing and make the preview a full yellow block, same with in editor. Are you saying my image B setup works for you in your editor? I’m on unity 2021.3.21f1. Do you know why it works in preview but not in editor for me? What does proper R value mean?
Yes, setup B works for me. What I mean by proper R value is that you are feeding a Vector4 (RGBA) in a float node. So it takes the R channel only. So the alpha will be based on the Red value of the texture. Which should be fine with a black and white texture. in 2021.3.0
The real reason is I did not drag the texture2d into it in editor. I did not understand that inside shader graph, what it simulates is the “default” texture you choose for that property. That’s why it never affect the change in editor. In editor, you need to drag it in. The only texture that it automatically knows is the MainTex. Also what tripped me up was UV node made it work but not otherwise making me think it was simply me doing the nodes wrong. I think the fact that you told me it works for you made me think it must be my settings somehow. Thank you for taking the time to set it up on your side to try it.