Search Unity

Masking Material (maybe Shader Graph)

Discussion in 'Universal Render Pipeline' started by MarkFaasen, Aug 29, 2020.

  1. MarkFaasen

    MarkFaasen

    Joined:
    Oct 23, 2018
    Posts:
    13
    Hey there,
    im very new to shaders but i believe this is a simple Quesiton. Using URP and the 2D Renderer
    So i have these 3D Objects stacked to create a 2d magic thing:
    upload_2020-8-29_15-11-6.png

    The objects are basicly a planes with extra faces on the rim so i can assign a second material for the rim. The middle faces have this shader to mask the objects behind
    Using this shader:
    Code (CSharp):
    1. Shader "Masked/Mask" {
    2.     SubShader {
    3.         // Render the mask after regular geometry, but before masked geometry and transparent things.
    4.         Tags {"Queue" = "Geometry+10" }
    5.         // Don't draw in the RGBA channels; just the depth buffer
    6.         ColorMask 0
    7.         ZWrite On
    8.         // Do nothing specific in the pass:
    9.         Pass {}
    10.     }
    11. }
    To create this Effect:
    upload_2020-8-29_15-11-36.png


    This works aslong as i use the URP/2D/Sprite-Lit-Default material. But assigning colors (i need HDR for glow) is difficult. So i tried the URP/Simple Lit shader (surface type Transparent) also working with the Masking but for some reason i can get it to use the Emmision Color. (Checked the tickbox and set the color, thats all right?).
    So then i thought about shader graph, HDR emission working great but unfortunetly i cant get the masking to work. Is there a way to tell shadergraph to use Depth/Stencil Buffer? This would be my favorite solution as i then can assign fancy effects to the magic circles! :D
    If that is not possible i would be very grateful for assistnace to writing a custom shader that just uses HDR color and is compatible with the masking. (i tried and failed utterly)
    Thank you so much for your Time!
     
  2. MarkFaasen

    MarkFaasen

    Joined:
    Oct 23, 2018
    Posts:
    13
    I solved this changing the Renderqueue to Transparent (3000) of the material with the shadergraph shader. In URP v10 this is included in the Node Editor