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. Dismiss Notice

Question Custom shaders make mesh invisible in URP 2021.3.22f1 (SOLVED)

Discussion in 'Shaders' started by toske_, Apr 7, 2023.

  1. toske_

    toske_

    Joined:
    Jul 21, 2018
    Posts:
    9
    Hello Everyone ! I'm having an issue with some custom shaders i wanted to port from previous Unity versions to the 2021.3.22f1.

    For some reason the code works on a 2D renderer, but not with a 3D urp renderer assets and actually no custom shader seems to work in the scene at all.

    upload_2023-4-7_17-7-4.png

    To test if its only my shader I've used simple unlit shader examples from unity own documentation and they also don't work. link to the example : https://docs.unity3d.com/Packages/c...riting-shaders-urp-basic-unlit-structure.html

    My scene is just a default empty 3d URP sample scene.

    Is there a bug in this version or something?

    Would appreciate any help, thanks !
     

    Attached Files:

  2. toske_

    toske_

    Joined:
    Jul 21, 2018
    Posts:
    9
    I figured out the problem. the setting in the URP renderer had Depth Priming Mode set on Auto, once its in disabled everything works perfectly.

    upload_2023-4-7_18-15-47.png

    I feel like if its on auto it should be smart enough to just render shaders as usual if they don't have a depth prepass.

    Anyway if anyone is wondering why simple custom shaders don't work on URP 3D renderer it could be this.
     
    octav88 likes this.
  3. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    631
    Hi, seems that the custom shader doesn't have passes named "DepthOnly" and "DepthNormals". If you'd like to add them, you may refer to URP's Lit shader & its include files.

    Depth Priming is an optimization technique (mostly for desktop GPUs) that reduces the overdraw of opaque objects by only rendering pixels that have the same depth as the one in the depth render target.
     
    arunraj_selvaraj likes this.
  4. octav88

    octav88

    Joined:
    Oct 19, 2019
    Posts:
    3
    Thank you, that solved my problem. It's crazy that I had to dig a lot for this forum post to come up. I'm going to share it in the tutorial I was following
     
    toske_ likes this.