Search Unity

Bug Custom shaders not working in 2021.3 LTS

Discussion in 'Universal Render Pipeline' started by markus_unity31, Mar 24, 2023.

  1. markus_unity31

    markus_unity31

    Joined:
    Nov 9, 2021
    Posts:
    1
    Hi,

    I've had issues with invisible objects using the custom shader template from:
    https://docs.unity3d.com/Packages/c...riting-shaders-urp-basic-unlit-structure.html

    I initially noticed it in a project using 2021.3.19f1, but I downloaded the latest (2021.3.21f as of today) and created a new project with the 3D URP template and got the same problem. It does work with 2022.2.8f1 using:
    https://docs.unity3d.com/Packages/c...riting-shaders-urp-basic-unlit-structure.html

    The object does not render at all when opaque, but works fine when changed to transparent (whenever render queue over 2500).

    Can anyone confirm or is it just me?
     
  2. AbelChiu

    AbelChiu

    Joined:
    Nov 29, 2016
    Posts:
    12
    I have the same problem, switching to the Android platform also worked
     
  3. reddo

    reddo

    Joined:
    Jul 1, 2015
    Posts:
    39
    Same problem here as stated above when switching a project from Android to PC using 2021.3.21f.
    Also tested a fresh 3D URP project on 2021.3.23f. On PC platform, for example, a cube with Unlit/Texture shader is invisible, but when switching to Android it renders ok.
     
  4. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    769
    Hi, if the shader works well when changed to transparent or switching the build target to Android, I think it's because the shader doesn't have a DepthOnly pass (or DepthNormals pass when SSAO is set to normals mode).

    URP sets the Depth Priming to "Auto" by default, which will always be disabled on mobile devices. Depth Priming (Depth Prepass) is an overdraw optimization technique, and it requires a depth pass in your shader.

    You can either disable Depth Priming or add a DepthOnly pass to the shader. You don't need to output the depth in the fragment shader, just copy the Unlit pass and add
    "LightMode" = "DepthOnly"
    to the tags.

    For example:
    Code (CSharp):
    1. Pass
    2. {
    3.     Name "DepthOnly"
    4.     Tags
    5.     {
    6.         "LightMode" = "DepthOnly"
    7.     }
    8.     // ...
    9. }
     
    ElliotB likes this.
  5. reddo

    reddo

    Joined:
    Jul 1, 2015
    Posts:
    39
    @wwWwwwW1, thanks very much for the pointer. That fixed it.
     
    wwWwwwW1 likes this.
  6. fanglore

    fanglore

    Joined:
    Jan 3, 2023
    Posts:
    3
    I have the same issue, but I believe I do not have shaders at all. I have a model imported from Blender and its material. If i set Transparent Surface Type in material, the model appears in camera view. But otherwise it is invisible. I have skin mesh renderer on it. How can I fix that problem?
    Also, if I create new project from 3D Core template (not 3D URP) there is no such problem. So it is reproduced only for 3D URP. My Unity version is 2022.1.13f1
    I hope for your help
    @wwWwwwW1
     
  7. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    769
    Hi, is the material using Lit shader? Will this be solved after disabling rigging & animation in the model's import inspector?

    I'm not sure what could be the problem according to your description, but you can try upgrading the Unity version to something like 2022.3 and see if it still happens.

    URP 13 (2022.1) is a strange version which doesn't have new features like FSR 1.0 backported to while URP 12 (2021.3) has. So I suggest testing this in another version of URP.