Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Sprite Unlit shader does not alpha correctly when used on Overlay Canvas

Discussion in 'Universal Render Pipeline' started by Peeling, May 28, 2022.

  1. Peeling

    Peeling

    Joined:
    Nov 10, 2013
    Posts:
    442
    To repro:

    1. Create a URP "Sprite Unlit" shadergraph
    2. Add a Texture2D input
    3. Add a Sample Texture 2D node
    4. Hook the Texture2D to the SampleTexture2D
    5. Hook the RGBA output of the Sample Texture to the Fragment Base Color
    6. Hook the A output of the Sample Texture to the Fragment Alpha
    7. Create a material and set the shader to the graph you have just created
    8. Drag in an image with alpha transparency as the Texture2D input
    9. Create an Overlay canvas and put two Images or RawImages on it
    10. Set the material of both Images or RawImages to the material you have just created
    You will observe that the two images alpha correctly with each other, and with the rest of the scene in scene view, but that in game view they block out full solid rectangles of some random colour (I've seen it be black, dark red - it's unpredictable):

    Scene View:
    upload_2022-5-27_18-28-34.png

    Game View:
    upload_2022-5-27_18-29-35.png

    Green = transparency is blending correctly
    Red = transparency is incorrectly rendering as solid

    This problem goes away if the canvas is switched to Screen Space - Camera.
     
  2. xaldin-76

    xaldin-76

    Joined:
    Oct 1, 2016
    Posts:
    25
    Any workaround for this? I think I'm having this bug on 2021.3.10f1