Search Unity

Question Is it possible to create a Depth Mask via Shader Graph?

Discussion in 'Shader Graph' started by ichabodcole, Jul 10, 2019.

  1. ichabodcole

    ichabodcole

    Joined:
    Aug 23, 2014
    Posts:
    3
    I'm just getting started with Shader Graph, and one of the first things I needed to create was a Depth Mask material so I figured I would try to recreate the shader via SG. Unfortunately, I can't for the life of me figure out if this is currently possible with Shader Graph, or what the equivalent would be.

    My main question is how can I replicate the ColorMask 0 and ZWrite On properties in SG?

    Below is an example of the standard shader code for creating a DepthMask shader. The applied material results in an invisible object that still writes to the depth buffer, allowing it to mask/hide parts of other objects within it or behind it by adjusting the render queue order.

    Code (CSharp):
    1. Shader "Masked/Mask" {
    2.     SubShader {
    3.         // Render the mask after regular geometry, but before masked geometry and
    4.         // transparent things.
    5.         Tags {"Queue" = "Geometry+10" }
    6.         // Don't draw in the RGBA channels; just the depth buffer
    7.         ColorMask 0
    8.         ZWrite On
    9.         // Do nothing specific in the pass:
    10.         Pass {}
    11.     }
    12. }
    Thanks for any assistance
     
    cptSwing likes this.
  2. cptSwing

    cptSwing

    Joined:
    Jul 2, 2015
    Posts:
    8
    This would interest me as well!