Search Unity

Question See dithered character through object

Discussion in 'Shaders' started by mrtenda, Mar 30, 2023.

  1. mrtenda

    mrtenda

    Joined:
    Jun 6, 2017
    Posts:
    73
    Hi, I'm stumped on how to achieve something in Unity and would be thankful for any help!

    Is it possible in Unity to achieve a similar effect as in Super Mario Odyssey where, when part of Mario is obscured by an object in the foreground, Mario's dithered silhouette is rendered on top? See image below.

    I am aware that there's a dithering node in Shader Graph, but I'm not sure how to have the dithering only happen if a foreground object is obscuring the character (and also, how to make the dithered character render on top of the foreground object).

    I'm using the built-in render pipeline in Unity 2021.3.

     
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    You can't really do something like this with shader graph, as this requires a secondary shader pass and potentially using Stencil buffer.

    For the simplest approach with the least control, your second shader pass would render in the Transparent queue with
    ZTest LEqual
    so it renders when obscured by other opaque objects. And in this pass, render it dithered.

    You could make 2 materials with 2 different shader graphs and apply those to the character renderer, but it's cleaner to just write one shader so values/properties can easily be shared between the passes, and you don't have to keep 2 materials' properties in sync.
     
  3. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074