Search Unity

Resolved Shader Graph UI Image Shader does not work

Discussion in 'Shader Graph' started by Seromu, Nov 24, 2021.

  1. Seromu

    Seromu

    Joined:
    Nov 30, 2015
    Posts:
    34
    Unity 2021.2.3f1
    Shader Graph 12.1.1

    This is a simple Shader Graph shader.

    Screenshot1. Universal - Material - Sprite Unlit: Alpha is wrong.
    whatswrong.png


    Screenshot2. Universal - Material - Unlit: Something weird texture.
    whatswrong2.png
     
    DavidZobrist likes this.
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    I don't think Sprite Unlit shader is supposed to work in UI, plus I think _MainTex should not be exposed if you want to use image set in Image component.

    Meanwhile I just tested how it works in my project and Unlit shader graph does not work at all in game view - there is just black square and ironically Sprite Unlit displays something, but it's broken:
    upload_2021-11-24_12-2-10.png
     
    Seromu likes this.
  3. MiguelBest

    MiguelBest

    Joined:
    Oct 22, 2018
    Posts:
    17
    I just updated my project from 2020 LTS to 2021.2 and have the same problem.

    All my UI elements which use a shader graph material now have a black background where they should be transparent. It works fine when setting the canvas screen space to 'Camera' (so that's something you could do for now, @Seromu) but I need my canvas to be 'Overlay'.

    Unity_NMTFfwpWAK.jpg

    Really hope this gets fixed otherwise I'll need to roll back to 2020 LTS.

    Edit: I've submitted a bug report, I'll come back with the link once it's up on the Issue Tracker.
     
    Last edited: Nov 24, 2021
  4. MiguelBest

    MiguelBest

    Joined:
    Oct 22, 2018
    Posts:
    17
    @ali_mohebali Do you mind looking into this? I've submitted a bug report but haven't heard anything back.
     
    Seromu likes this.
  5. MiguelBest

    MiguelBest

    Joined:
    Oct 22, 2018
    Posts:
    17
    For anyone wanting to use an Overlay canvas and having the same issue, a workaround is to create a new layer and assign your UI to said layer. Then create a new 'Render Objects' Renderer Feature and set its Event to 'After Rendering'. You'll need to set the Queue to 'Transparent' and Layer Mask to your newly created layer.

    The canvas Render Mode will also have to be set to 'Screen Space - Camera' but it will still be treated as an Overlay canvas.
     
  6. Seromu

    Seromu

    Joined:
    Nov 30, 2015
    Posts:
    34
    Thygrrr and macka1080 like this.
  7. MiguelBest

    MiguelBest

    Joined:
    Oct 22, 2018
    Posts:
    17
    I finally got an email saying they were able to reproduce the bug and it's now up on the issue tracker. You can vote for it here: https://issuetracker.unity3d.com/product/unity/issues/guid/1383356

    It might be that they'll end up saying it's "by design" again but you never know. Even so, voting for this could raise more attention and maybe they'll push this issue up on their priority list.
     
    DavidZobrist and Seromu like this.
  8. DigitalSalmon

    DigitalSalmon

    Joined:
    Jul 29, 2013
    Posts:
    100
    Seems so weird that we even need a vote-based issue tracker. This is quite clearly a fundamental need.

    This issue has been known since before November 2021. It's February 2022. Four months. And that's just since this forum post.

    So bored of basic features being ignored. Beyond frustrated.
     
  9. SunnyValleyStudio

    SunnyValleyStudio

    Joined:
    Mar 24, 2017
    Posts:
    67
    I think that transparency will start working with a Sprite Unlit shader if you set the Canvas component to Render Mode Screen Space - Camera and assign the MainCamera as the Render Camrera.

    I hope it helps!

    upload_2022-2-21_15-49-5.png
     
  10. DigitalSalmon

    DigitalSalmon

    Joined:
    Jul 29, 2013
    Posts:
    100
    I appreciate the attempt to help, but, Screen Space - Overlay exists for a (very good) reason.

    Whilst it's great that Camera works, for as long as Overlay doesn't work this feature is not finished, and the absolute lack of communication (or progress) from the ShaderGraph team is not up to par.
     
  11. Fressbrett

    Fressbrett

    Joined:
    Apr 11, 2018
    Posts:
    97
    We just upgraded from 2021.1.20f1 to 2021.2.12f1 and experienced this very issue. All UI images that use custom ShaderGraph materials, to for instance animate a shine-effect onto the image, now render black where they should be rendering transparent. Within the scene view everything looks fine, but in the Game view the issue appears.

    This seems like a very annoying bug, which now seems to exist for months without any updates. The devised workaround to set the Canvas mode to "Screen Space - Camera" and put all UI elements on a layer that is referenced within a URP RenderFeature set to AfterRenderingPostProcessing DOES work for us. Although this pretty much defeats the purpose of Overlay Canvases altogether and intoduces additional overhead due to the extra RenderFeature needed.

    Please don't forget to vote the issue up, so that it might get fixed soon!

    I added a comment to the issue and cross-referenced this thread, in hopes anyone reviewing it might get an immediate sense for the scale of the problem, given the screenshots that appeared within this thread.
     
    Last edited: Feb 23, 2022
    Seromu likes this.
  12. DigitalSalmon

    DigitalSalmon

    Joined:
    Jul 29, 2013
    Posts:
    100
    No replies from a Unity dev in the ShaderGraph forum since July, it's not looking good friends :eek:
     
    Fressbrett and Seromu like this.
  13. Fressbrett

    Fressbrett

    Joined:
    Apr 11, 2018
    Posts:
    97
    Update: The issue has been set by Unity to "By Design", giving the following reason:

    ...hopefully this "coincidence" comes back a few package versions down the road.
    But hey, at least there is yet another page to vote for the issue, so I guess in the meantime let's do that
     
    Last edited: Feb 25, 2022
    MiguelBest and Seromu like this.
  14. MiguelBest

    MiguelBest

    Joined:
    Oct 22, 2018
    Posts:
    17
    Welp, that's disappointing.

    I guess all we can do now is mark it as "Critical" on the product board then. Or use Amplify Shader Editor, they seem to support UI.
     
    Seromu likes this.
  15. uzisho

    uzisho

    Joined:
    Jul 3, 2019
    Posts:
    14
    Hi - had a similar issue with shadergraph material not working on a UI image.
    What eventually worked for me is:
    - ScreenSpace Overlay
    - Additional Shader Channels: TexCoord1

    The "TexCoord1" Channel by itself is critical and please check it doesn't change on runtime.

    On my other canvas TextMeshPro triggers the tangent and normal channels which made the material not appear. Please note that those are automatically triggered by TextMeshPro even if unselected before pressing Play.



     
    Last edited: Mar 12, 2022
    FM-Productions and Seromu like this.
  16. Master_Davicous

    Master_Davicous

    Joined:
    Apr 29, 2016
    Posts:
    11
    @uzisho your solution did not work for me. Really disappointed in Unity with this. I can't believe it's been known about for months and the problem still exists on an LTS version...
     
    Seromu likes this.
  17. Seromu

    Seromu

    Joined:
    Nov 30, 2015
    Posts:
    34
    Unfortunately, the only solution is setting the canvas screen space to 'Camera'. :(
     
  18. mia_01

    mia_01

    Joined:
    Sep 21, 2020
    Posts:
    3
    This is horrendous. How is this not just a basic feature of Shader Graph? Does Unity think that no one would want to use a shader on a UI object? That seems extremely obvious to me.
     
  19. mia_01

    mia_01

    Joined:
    Sep 21, 2020
    Posts:
    3
    Alright, this is my workaround.

    • Create a new Camera and set the Render Type to Overlay and Projection to Orthographic
    • Set the Culling Mask to UI
    • Go to the base Camera and find the "Stack" option, and add the new Camera to the Stack.
    • Put the UI elements with all the Shaders onto a Canvas set to Screen Space - Camera, and set the Camera to the Overlay camera
    For me it's working identically to Render Mode. I'm not smart enough to know the differences between this and the Canvas Overlay mode. This is a bit ridiculous though
     
    Last edited: Jul 18, 2022
    ltlejeune and MatVic like this.
  20. hexdecc

    hexdecc

    Joined:
    Oct 24, 2014
    Posts:
    148
    remove source image only use material,
    you are displaying 2 image, one source image second one base_Texture with shader this is what's wrong.
     
  21. sonolil

    sonolil

    Joined:
    Mar 15, 2015
    Posts:
    14
    So far MiguelBest's was the most stable fix. But I hope they find a workaround (despite being 3 months late) because having to create a new layer and a RendererObject every project is not very scalable. I did vote for now.
     
  22. Seromu

    Seromu

    Joined:
    Nov 30, 2015
    Posts:
    34
    'Source Image: None' doesn't works for me.

    Sprite Unlit
    upload_2022-7-21_12-7-42.png

    Unlit
    upload_2022-7-21_12-11-19.png
     
  23. timzydee

    timzydee

    Joined:
    Mar 18, 2013
    Posts:
    8
    Other possible workarounds...

    Mask the sprite to eliminate the black areas
    Check UseSpriteMesh can also remove some of the black areas

    These are entirely dependent on the shape of the sprite and don't address partial transparency
    In my case I have a simple solid circle
     
  24. Regone

    Regone

    Joined:
    Aug 1, 2014
    Posts:
    35
    Did anyone get a workaround other than making two cameras and removing the canvas from overlay mode?

    I "mistakenly" versioned up my unity, used much good stuff from it, and after a month of hard work I see that many of the UI shaders such as these nice clouds got all fudged up :\

    And it's all good in the viewport, that's the funny part...
    upload_2022-8-25_4-34-5.png
     
  25. jessmwoodward

    jessmwoodward

    Joined:
    May 13, 2021
    Posts:
    4
    I couldn't get the above suggestions working for me, so tried something else. It's not an ideal solution, but if you're not using many UI shaders maybe it'll do.

    I noticed that the generated code from the 2020 version of one of my Shadergraphs seems to behave properly in 2021. Looking at the difference in generated code between the two, it looks like 2021 introduces two extra passes - titled SceneSelectionPass and ScenePickingPass.

    I copied the generated code from one of my Shadergraphs into a standard surface shader doc, deleted those two passes out, saved it, and now my UI alpha is rendering properly again. I'm yet to do a build so YMMV (though it displays fine in both Scene view and Game/Device Simulator view), but I'm tentatively hopeful it'll do the trick.

    Specifically, the sections I deleted are:


    Pass
    {
    Name "SceneSelectionPass"

    ..........

    #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/SelectionPickingPass.hlsl"

    ENDHLSL
    }
    Pass
    {
    Name "ScenePickingPass"

    ............

    #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/SelectionPickingPass.hlsl"

    ENDHLSL
    }


    The resulting shader code only has two passes - both titled "Sprite Unlit" (one for Lightmode Universal2D and the other for Lightmode Universal Forward).
     
  26. Sabrino

    Sabrino

    Joined:
    Aug 8, 2015
    Posts:
    35
    It is really bad that this has not been fixed.

    Thank you jessmwoodward for your suggestion. It does work in a build as well. Clearly not a practical solution for many, but it's a life saver in my use case.
     
  27. AlterHaudegen

    AlterHaudegen

    Joined:
    Jul 8, 2013
    Posts:
    28
    Camera stacking solves the issue - until you want to use dynamic resolution (or post processing excluding the UI...), which affects all cameras in a stack. It's all circular depending "by design" unusable systems all the way.
     
  28. LEGENDARY_L

    LEGENDARY_L

    Joined:
    Dec 31, 2015
    Posts:
    7
    I had this issue earlier today. The way I fixed it was by replacing the Image element with a Raw Image. If you also end up getting a weird red background, just reopen the project. It can happen during Redo and Undo actions.
     
  29. scriptwelder

    scriptwelder

    Joined:
    Feb 26, 2017
    Posts:
    3
    THANK YOU ! This worked for me!
    I couldn't use stacking cameras because I'm using Pixel Perfect Camera component, so this solution is a lifesaver.
    Just save all graph-generated shaders as regular shaders and delete the sections mentioned by jessmwoodward
     
    MrDizzle26 likes this.
  30. Florian-G

    Florian-G

    Joined:
    Jun 26, 2015
    Posts:
    3
    Building on jessmwoodward's suggestion, I thought I'd post this a simple template of a HLSL shader for UI.

    Code (CSharp):
    1. Shader "URP/UI/PolarShader"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex ("Texture", 2D) = "white" {}
    6.         _Alpha ("Transparency", Range (0, 1)) = 0.5
    7.     }
    8.     SubShader
    9.     {
    10.         Tags
    11.         {
    12.             "RenderPipeline"="UniversalPipeline"
    13.             "RenderType"="Transparent"
    14.             "Queue"="Geometry"
    15.         }
    16.  
    17.         Pass
    18.         {
    19.             Cull Back
    20.             Blend SrcAlpha OneMinusSrcAlpha
    21.             ZTest LEqual
    22.             ZWrite On
    23.  
    24.             HLSLPROGRAM
    25.             #pragma vertex vert
    26.             #pragma fragment frag
    27.  
    28.             #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
    29.  
    30.             // user defined variables
    31.             sampler2D _MainTex;
    32.             float4 _MainTex_ST;
    33.             half _Alpha;
    34.  
    35.             // vertex input
    36.             struct appdata
    37.             {
    38.                 float4 pos : POSITION;
    39.                 half2 uv : TEXCOORD0;
    40.             };
    41.  
    42.             // vertex output
    43.             struct v2f
    44.             {
    45.                 float4 pos : SV_POSITION;
    46.                 half2 uv : TEXCOORD0;
    47.             };
    48.  
    49.             v2f vert (appdata v)
    50.             {
    51.                 v2f o;
    52.                 o.pos = TransformObjectToHClip(v.pos);
    53.                 o.uv = v.uv;
    54.                 return o;
    55.             }
    56.  
    57.             half4 frag (v2f i) : SV_Target
    58.             {
    59.                 half2 scale = half2(1, 1);
    60.                 half2 position = _MainTex_ST.xy;
    61.                 half2 polarScale = half2(1, 1);
    62.                 half2 polarPosition = _MainTex_ST.zw;
    63.  
    64.                 // UVs
    65.                 half2 offset = half2 (0.5, 0.5) + position;
    66.                 half t = atan((offset.x - i.uv.x * scale.x) / (offset.y - i.uv.y * scale.y)) / 3.14159265359f;
    67.                 half r = distance(offset, i.uv * scale);
    68.  
    69.                 half4 tex = tex2D(_MainTex, half2 (t, r) * polarScale + polarPosition);
    70.  
    71.                 return half4(tex.rgb, _Alpha);
    72.             }
    73.             ENDHLSL
    74.         }
    75.     }
    76. }
     
    MrDizzle26 and adamgryu like this.
  31. Qhuhuit

    Qhuhuit

    Joined:
    Feb 17, 2018
    Posts:
    39
    @jessmwoodward Thank you, this is working in Unity 2021.3.16.
    Unity said "Making this a reliable and supported feature will require a bit of cooperation from a few other teams," ...
    I wonder how hard is it to write a script that removes those two passes automatically and how many teams are needed for that xD
     
  32. RafaelGaju

    RafaelGaju

    Joined:
    Apr 8, 2020
    Posts:
    3
    Hello, how did you make it work? I tried copying the generated code from shadergrapg into a standard surface shader and delete those sections @jessmwoodward mentioned but it still doesnt work for me. I think i could have gotten wrong what sections need to be deleted were, can you please elaborate a little? Thank you
     
    Last edited: Feb 14, 2023
  33. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    285
    Removing those two sections did work for me as well.
    For those who do not know how to do it:
    1. select your `.shadergraph` asset inside Unity
    2. on Inspector, click the button View Generated Shader
    3. Copy the `.shader` script to your assets folder and then remove the sections described by @jessmwoodward
    4. Find all the materials using the original shader and replace them with that copy

    upload_2023-1-28_2-36-33.png
     
  34. ltlejeune

    ltlejeune

    Joined:
    Aug 6, 2019
    Posts:
    24
    You guys have saved my project, an eternal thanks.
     
    sandolkakos likes this.
  35. florentsteiner

    florentsteiner

    Joined:
    Apr 13, 2021
    Posts:
    8
  36. oskar_s

    oskar_s

    Joined:
    Oct 8, 2020
    Posts:
    1
    Unfortunately @jessmwoodward @sandolkakos your fix didn't work for me. Without this sections shader still compiles and works just the same as before but is still bugged and black in Game view.
     
  37. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    285
    I do not have experience with shader to try to help you :(
     
  38. jessmwoodward

    jessmwoodward

    Joined:
    May 13, 2021
    Posts:
    4
    I'm so glad my fix was helpful! I'm chatting with @oskar_s separately but for anyone else who has trouble with that fix, some things you could look into (please take these with a grain of salt, I'm still pretty new to shaders and VERY happy to be corrected by someone who actually knows what they're doing!):

    • What Passes are in your shader? Are there any you can get rid of? If your Shadergraph is just one graph with no subgraphs there's a good chance you can get rid of all of them after the first one. (Save a backup copy first to be safe - we tried this on Oskar_s' shader and deleted too many passes, oops!)
    • Deleting any Light/Shadow stuff in the Properties section might help (I'm not sure if the way Unity does UI can use Lightmaps & ShadowMasks so may as well delete it if you're not deliberately using it).
    • I've also found that when I have only one Pass, moving the Render State section from inside the Pass to just before the Pass has worked.

    .......
    // Render State
    Cull Off
    Lighting Off
    Blend SrcAlpha OneMinusSrcAlpha
    ZTest [unity_GUIZTestMode]
    ZWrite Off

    Pass
    {
    Name "Default"
    .......


    • When all else fails: Open the Default Unity UI shader and run both it and your shader through DiffChecker. Try make your file as consistent with the Default one as possible except for your custom Properties, and the stuff between the first HLSLPROGRAM and the first ENDHLSL (which is where your custom shadergraph stuff is).
     
    Last edited: Feb 25, 2023
    Tete8008 and sandolkakos like this.
  39. RyFridge

    RyFridge

    Joined:
    Apr 7, 2014
    Posts:
    52
    Thank you so much for this fix, this worked for my project as well (Unity 2021.3.14f1)! A bit tedious to do by hand though, and definitely not what the Shader Graph is all about: being easy and fun to use.

    Someone at Unity should alter the shader generator script to exclude these two passes for a "UI Unlit" Shader Graph and everyone would be happy.
     
    Glader and sandolkakos like this.
  40. CryShana

    CryShana

    Joined:
    Nov 30, 2013
    Posts:
    12
    Can confirm it works.

    I had an "Unlit" shadergraph (not "Sprite unlit"), set the surface type to "Transparent" and blend mode to "Alpha". I saved it and copied the generated shader code to another file.

    I changed the name of the shader in that file (name is on the top line) so it's unique and easier to find (because I want to keep my original shadergraph and don't want same names)

    Then I scrolled all the way down and had to delete 4 different "Pass" sections related to lighting and shadows. Saved the changes and used it for my UI material.

    It now works both for overlay and world-space canvases both in-scene and in-game. Also tried building the game for PC and still worked. I tested this on Unity 2023.1.0b7. :)
     
    RyFridge and sandolkakos like this.
  41. Lexone

    Lexone

    Joined:
    Dec 9, 2015
    Posts:
    2
    Can confirm that jessmwoodward's solution of deleting these two passes from the generated shader code works.

    I tested this on Unity 2021.3.21f1 LTS

    Code (CSharp):
    1.    
    2. Pass
    3. {
    4.     Name "SceneSelectionPass"
    5.  
    6.     ........................
    7.  
    8.     #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/SelectionPickingPass.hlsl"
    9.  
    10.     ENDHLSL
    11. }
    12.  
    13. Pass
    14. {
    15.  
    16.     Name "ScenePickingPass"
    17.  
    18.     ........................
    19.  
    20.     #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/SelectionPickingPass.hlsl"
    21.  
    22.     ENDHLSL
    23. }
    24.  
     
    sandolkakos likes this.
  42. adritake

    adritake

    Joined:
    Oct 22, 2021
    Posts:
    1
    I just run into the same problem and I digged into the frame debugger where all the passes that your guys mentioned where showing up and screwing up the sprite:
    upload_2023-4-5_14-1-33.png
    upload_2023-4-5_14-1-49.png

    I don't want to update the generated shader code each time I change the shader graph so I suppose I'll go with an old school hand written shader. This is the base shader I am using (I'll include all the effects I need here):

    Code (CSharp):
    1. Shader "Unlit/UIActionButton_shader"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex ("Texture", 2D) = "white" { }
    6.     }
    7.     SubShader
    8.     {
    9.         Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
    10.         LOD 100
    11.         Blend SrcAlpha OneMinusSrcAlpha
    12.  
    13.         Pass
    14.         {
    15.             CGPROGRAM
    16.             #pragma vertex vert
    17.             #pragma fragment frag
    18.  
    19.             #include "UnityCG.cginc"
    20.  
    21.             struct appdata
    22.             {
    23.                 float4 vertex : POSITION;
    24.                 float2 uv : TEXCOORD0;
    25.             };
    26.  
    27.             struct v2f
    28.             {
    29.                 float2 uv : TEXCOORD0;
    30.                 float4 vertex : SV_POSITION;
    31.             };
    32.  
    33.             sampler2D _MainTex;
    34.             float4 _MainTex_ST;
    35.  
    36.             v2f vert(appdata v)
    37.             {
    38.                 v2f o;
    39.                 o.vertex = UnityObjectToClipPos(v.vertex);
    40.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
    41.                 return o;
    42.             }
    43.  
    44.             fixed4 frag(v2f i) : SV_Target
    45.             {
    46.                 fixed4 col = tex2D(_MainTex, i.uv);
    47.                 return col * col.a;
    48.             }
    49.             ENDCG
    50.         }
    51.     }
    52. }
    53.  
     
    adamgryu likes this.
  43. sonolil

    sonolil

    Joined:
    Mar 15, 2015
    Posts:
    14
    Is this still not fixed? I keep getting alerts for this thing.

    Actually I've been using a seperate overlay camera for my ui ever since. I found that it's much better to manage than having a humongous overlay canvas hanging around your scene. But I also understand the comments that don't want to switch to that workflow.

    Even so... won't Unity fix this? This still seems very basic and I'm still getting alerts and complaints. Like I said, I don't think copying the default shader and editing to fix it is a very scalable solution. I'm unfollowing this thread but please be aware of this issue, the staff who are responsible.
     
    guoboism and RyFridge like this.
  44. jessmwoodward

    jessmwoodward

    Joined:
    May 13, 2021
    Posts:
    4
    I ran into another quirk with this today, so thought I'd link here in case it's relevant to anyone else.

    In short, on Android devices my custom UI shader was disappearing whenever an OnApplicationFocus(false) event occurred. Had to weed out a few more chunks of shader code to stop it from happening:

    https://discussions.unity.com/t/ui-...he-application-is-sent-on-background/251770/2

    I'm with sonolil - I would love it if Unity either made Sprite Unlit compatible with UI again, or made an official UI Shadergraph version. Surely UI shaders would be a pretty popular use for Shadergraph.
     
    Last edited: Aug 11, 2023
    sandolkakos likes this.
  45. bebo77

    bebo77

    Joined:
    Aug 3, 2012
    Posts:
    84
    For me the texture works fine rather, does anyone know how to access the color parameter from Shadergraph?

    URP-UI-shadergraph-color.png


    I tried with _MainColor and _Color but it doesn't work.
    Urp_UI_color_Shadregraph.png
     
  46. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Try vertex color
     
    bebo77 likes this.
  47. bebo77

    bebo77

    Joined:
    Aug 3, 2012
    Posts:
    84
    Thank you so much!!!
     
  48. Seromu

    Seromu

    Joined:
    Nov 30, 2015
    Posts:
    34
    UI Integration with Shader Graph - Unity Platform - Rendering & Visual Effects | Product Roadmap (productboard.com)

    Finally!!!

    Beginning in 2023.2 beta 16, you can now select Canvas as a new Material Type in the Graph Inspector for HDRP, URP, and Built-In. This new Material Type creates shaders that are compatible with UGUI Canvas elements, such as Image. Using Shader Graph for UGUI Canvas elements allows users to create an infinite array of animated effects and tune the behavior and appearance of the UI while also reducing performance and memory costs.


    Unity 2023.2.0a18
    • Shadergraph: Enabled Shader Graph Canvas Master Node to allow users to create UI shaders for Canvas in HDRP, URP, and Built-in.
     
  49. LiamAttClarke

    LiamAttClarke

    Joined:
    Jun 19, 2023
    Posts:
    1
    I think I ran into the same issue some here have reported.

    My custom Sprite Unlit ShaderGraph was rendering transparency correctly in the scene view.

    Scene View:
    Screenshot 2023-06-19 122715.png

    But in game view, transparency seemed to revert to some serialized solid colour (in my case red):
    Screenshot 2023-06-19 122711.png

    Even though I was using the "Sprite Unlit" Material in my ShaderGraph, it seems the serialized "Alpha Clipping" property of the "Unlit" Material was causing the failure.

    I managed to get this working by doing the following:
    1. Switch your ShaderGraph to use "Material: Unlit" in the Graph Inspector.
    2. Activate "Alpha Clipping"
    3. Switch back to using "Material: Sprite Unlit"
    4. Save Asset

    Check out this recording I made of the issue:
     
    Masaicker, gooby429 and hywhld_ like this.
  50. FredMoreau

    FredMoreau

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    168
    Hi @LiamHeller,

    thanks for providing detailed feedback and taking the time to record a video.
    Let me ask which version of Unity, URP and Shader Graph are you using?
    As I just tested in 2023.2.0a17 and it seems to work just fine.

    Also, have you reported it as a bug?

    Thanks!
     
    TechGhost likes this.