Search Unity

How can I use a shader on an object that have another shader

Discussion in 'Shaders' started by darkwinds95, Oct 1, 2019.

  1. darkwinds95

    darkwinds95

    Joined:
    Dec 3, 2018
    Posts:
    14
    Hi,

    On my project, I want to use a shader that makes the character dissapear while the model already have a shader on it. this is for making the enemy dissapear in a certain way when he die. But I don't know how to do.

    upload_2019-10-1_23-32-50.png
    My character is like that and I want to make him dissapear like this


    Without having to replace the material he already have.

    If somebody have a solution it would be great.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Not really, no.

    Shaders are additive. You can add stuff on top of what is already there, but you can't take away what's already been drawn to reveal what was there before. As soon as the character's original shader finishes rendering, the information about what was behind it has been lost.

    There are some ugly hacks using multiple grab pass shaders, or pre-pass depth writing shaders, or rendering an object to an offscreen render texture. But those all come with additional caveats and issues, and all effectively mean you still need a custom shader for your character anyway. So really you'll just need to write a new version of the existing character shader that has the dissolve feature built in.
     
  3. darkwinds95

    darkwinds95

    Joined:
    Dec 3, 2018
    Posts:
    14
    Thanks for the answer =)
    Then I'll replace the material with the one with the dissolve and just make it as close as possible to the previous one.