2D URP + ShaderGraph + Graphics.Blit + Material + Transparency Question

I’m in Unity 2020.3 looking to use ShaderGraph to create a Shader which I can then use for a Material which will be used in a Graphics.Blit call. In my Graph Settings > Target Settings, if I use “Unlit”, the Blit call simply results in the RenderTexture being completely transparent, but if I use “Sprite Unlit” I can get everything working except transparency. When I do this, the resulting RenderTexture always has an alpha of 1 for the entirety of the texture, no matter what the ShaderGraph’s alpha output is set to.

Perhaps there’s some other way to achieve this, but is there a way I can use a ShaderGraph-based Material and “apply” it to an input texture and get an output texture that has 4 channels of data? Thank you.

1 Like

Still looking for some help with this. It seems like maybe it’s a bug with Graphics.Blit and URP interaction, but whether it’s intended or not to ignore the alpha channel to not be considered when doing a Graphics.Blit call, I need some workaround if anyone is also working in 2D URP + ShaderGraph and has found something that works.

I’ve found a pretty silly workaround for this:
The issue is with the Blend mode specified in the generated shader code. If you generate code from your ShaderGraph, and then manually remove the , One OneMinusSrcAlpha bit from the Blend mode in the “Sprite Unlit” pass, it will observe the correct alpha. I cannot find any way to reproduce this from within the ShaderGraph interface.

1 Like