Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    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:
    344
    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:
    24
    Any workaround for this? I think I'm having this bug on 2021.3.10f1