Search Unity

HRDP Stencil shader OR Depth Mask Culling [Insight Requested]

Discussion in 'High Definition Render Pipeline' started by keromonkey, Dec 20, 2019.

  1. keromonkey

    keromonkey

    Joined:
    Jan 16, 2019
    Posts:
    42
    [I'm on Unity 2019.2, using HDRP 6.7.1]

    Hello, I'm looking for insight on seeing through Terrain in a specific spot
    (or rendering terrain invisible in a specific spot).

    In default pipeline, there are stencil shaders & depth cull masking techniques.
    But they appear not to work out of the box in HDRP.

    I understand HDRP uses deferred rendering.
    (Not sure what that means exactly,
    but it sounds like it queues things up and renders them later).

    But, if so, how do I take advantage of it to "see through terrain".

    To give you a better visual of what I'm trying to do:

    [Proc Gen a hole mesh, realtime.
    This black sheet is the surface mesh, placed above the terrain with the intention of seeing through the terrain to reveal the rest of the mesh
    ]



    [This brown mesh below would be the rest of the mesh, though its supposed to be underground.
    I want to use the black hole above as a depth mask to hide the terrain layer
    and see the inside of the brown mesh
    (which will normally be below terrain level).]




    Traditionally, a "simple" depth mask shader seems like it might be the way to go. But since that doesn't work 1:1 in HDRP, surely there must be an HDRP version of this. Or some way to write a working mask for the TerrainLit Shader.

    [If it helps, I've attached the TerrainLit shader]

    p.s. plz don't make me write a volumetric shader for this >_>
    (It defeats all the effort of writing the proc gen mesh script)
     

    Attached Files:

    Last edited: Dec 20, 2019
  2. Mojo-Game-Studio

    Mojo-Game-Studio

    Joined:
    Sep 18, 2015
    Posts:
    111
    Did you ever solve this?
     
  3. keromonkey

    keromonkey

    Joined:
    Jan 16, 2019
    Posts:
    42
    The next version of Unity came out with Terrain Holes so I didn't need to.
    Shaders aren't yet my expertise, however - although I would still find this to be a very useful skill to write HDRP shaders.