Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question See dithered character through object

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

  1. mrtenda


    Jun 6, 2017
    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


    Nov 7, 2013
    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


    Jul 7, 2012