Maskable UI Shader

We are always struggling with new shaders for our UI-Only game. The main reason for that is the lack of UI support from Shader Graph, mostly masking.

None of the generated shader graph shaders respect the UI masking ( Mask & 2D RectMask). In the previous version (2019.4) we were able to manually go into the shader code and add these lines in order to work around this limitation.
However, after the update to 2020.4 and the new master nodes this doesn’t work anymore. Firstly the generated shader is not ~300 lines of code anymore, but ~1800 (which is ridiculous) but there are multiple SubShaders defined, which makes it confusing where to put these lines. I managed to get the simple mask working, when deleting half of the code, so that only one SubShader exists, but this doesn’t fix the rect mask anymore.

Also the UnityEngine.UI Image component won’t let us tint the UI images anymore, even though the color property was created using the _Color accessor.
I feel like URP is a ton of spaghetti code, maybe its not for a 3D only project, but we are heaving a hard time to get our project running again.

3 Likes

+1 Shader Graph really needs native support for Sprite Masks and Rect Mask 2D. I tried looking into the generated shader to place the keywords you mentioned in the links above (thanks :smile:) but immediately lost hope after seeing that the generated code is more than 7000 lines long (for a graph with just 4 nodes).

3 Likes

This feature is currently marked Planned on the Product Board. But that likely means 1+ years away.

The best workaround is to start from the default non-SG UI shader.

I am having this problem too trying to find a solution. When I generate Unity code to try and create a stand alone shader from it, I get a syntax error right out the of the gate before I even touch anything. :-/

The last thing I want to do is used some pre-rendered transitions for my UI when I could simply create a shader graph that does what I want and would actually be versatile.

Has this still not been done in 2023?

2 Likes

This is still not a thing in 2024

Still not a thing in 2025.