Search Unity

Shader for turning a Material solid color, then fading it

Discussion in 'General Graphics' started by echoic, Feb 5, 2015.

  1. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    91
    Not sure if this is possible, but I'm looking for a way to turn my Character's material solid, then fade it slightly via alpha to give it a ghostly appearance. The closest I've been able to get is this awful result (see attached image), in which lowering the alpha reveals character parts that are meant to be hidden. I essentially want to make my character a silhouette, but slightly see-through.

    Any ideas? Thank you!
     

    Attached Files:

  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    The character needs to be one piece instead of several separate elements.
    Unless you're able to work up a shader that can do additive/subtractive stuff on overlapping elements.
    May want to temporarily swap out the separate character for solid character - if this is only a temporary effect.
     
  3. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    91
    Unfortunately, it's not just a temporary thing.

    Wish there were a way to decrease the opacity of a camera... lol. Would make it so much easier.
     
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    rookie question - could you edit the visibility of the layer? Or possibly a alpha mask camera pass on the character layer that could control the visibility of the character.
    @imaginaryhuman could possibly have a specific process to accomplish this.
     
  5. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    91
    Hmmm... well I've figured out that I can't make a layer semi-transparent and I can't have a shader ignore a layer. Seems impossible at this point... least with my skillset.

    Still, it'd be cool to give my players invisibility, since they've been asking for it, hehe.

    Thanks for your help theANMATOR2b! I'll keep researching.
     
  6. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Just a thought bubble :)
    you are using bones to control the animations correct? I only assume this by the way your character is constructed looking at the picture you provided.
    Couldn't you create a set of different body parts and swap out the current character parts with new transparent ones while keeping the animation tree (state machine) intact.

    If not - since this is one of the core elements of game play may consider reworking the animation system to be modular, or at least friendly to swapping out sprites/body parts.

    Maybe this leads to another thought that can work.
     
  7. echoic

    echoic

    Joined:
    Apr 29, 2011
    Posts:
    91
    Aye, I'm using bones. I think your suggestion would ultimately look the same as the image I posted, though (if I made each of the textures semi-transparent). (Never mind the hands and neck in the picture, I forgot to reduce opacity on those.)

    Unless you mean something else?
     
  8. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    I'm looking for a similar shader. I suppose it could be done with compositing premultiplied alpha. So pixels in the same layer are combined with no alpha but then alpha is applied as normal during the blending phase.

    --

    Alternatively, have you considered rendering your character into a texture and then applying alpha to that texture in front of the main camera? This would yield the same effect.

    Unfortunately, the render to texture approach will not work for me as I have a very large area of the screen to cover.
     
  9. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Dang @echoic - sorry I didn't see your post update until now.

    I was actually thinking of something like this
    TransparentCharacter.jpg
    Replacing the existing character with a thin outlined version of the character. Of course it would have to be setup the same as you have your current character but the individual body parts could be swapped out with outlined body parts. And at the joint intersections, the outlines would fade to nothing.
    Here is another example
    TransparentIdea.jpg
    The grey in the background is only for body part representation, would not be in the actual map/sprite.
    Each body part is separate, and doesn't touch, so there is no risk of overlapping additive transparent parts. Each part would only be thin, outlines representing the shape of the body part (illusion of invisibility with a sprite swap).
    I think this - with a cool shimmering or transparent water like refractive shader effect could end up looking pretty cool!

    Just a thought, I know this is a late reply and you've probably already solved the issue.

    Post an update of the solution you used.