Search Unity

Question How to disable depth test in shader graph?

Discussion in 'Shader Graph' started by zhuchun, Jul 13, 2019.

  1. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I'm using HDRP, is that possible to disable depth test and make the outline highlighter effect?
     
  2. darkesco

    darkesco

    Joined:
    Mar 19, 2015
    Posts:
    61
    I'm pretty sure that depth test can be disabled, but googling and asking around has not turned up anything. It was suggested that you can convert your shader graph to code and add the ZTEST flag, but I couldn't get that to work. As for outline, you can do this with a texture swap. You could also use a multiplication of a fresnel and hdr color node. If you need neon or something like that you will probably have to use post processing.
     
    Arkade likes this.
  3. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Thank you, but regarding disabling depth test, I want an object to show its silhouette behind an obstacle.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Like @darkesco mentioned, Shader Graph currently offers no option for disabling depth test, or modifying any other render state settings directly. Unity has said it's something on their list of things to do, but it's not available yet, and might not even be something they've started working on.

    The only option is to not use Shader Graph and use a vertex fragment shader. If you right click on your master node you'll get the option to copy the generated shader code which you can paste into a file and use instead of the Shader Graph, as well as modify to meet your needs.
     
    Arkade and zhuchun like this.
  5. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Oh, that's a good work around!
     
  6. gary_beebe

    gary_beebe

    Joined:
    Sep 6, 2017
    Posts:
    1
    In URP, you can add an Object Renderer override to your URP_Renderer.asset. Set the Override Layer Mask to a layer that you want to always render over top of everything and set Depth to Always.
     
    jamespaterson and marcospgp like this.
  7. BrutifulGames

    BrutifulGames

    Joined:
    Jan 14, 2013
    Posts:
    3
    jamespaterson likes this.