Search Unity

Question on "Mask" shader effect of "Space Marshals" (IOS)

Discussion in 'Shaders' started by michael-y, Jan 27, 2015.

  1. michael-y

    michael-y

    Joined:
    Apr 9, 2013
    Posts:
    18
    Guys,
    I've recently been playing on IOS game "Space Marshals" , though I don't know the technical detail of this game, I'm still wondering the principle of "Mask" object effect in unity3D's shader:

    The character's body is dynamically masked by the building. as you can see in the snapshot. How can I make this happen in unity3D? By AlphaBlend or stencil buffer I guess?

    SpaceMarshals Snapshot01.jpg SpaceMarshals Snapshot02.jpg
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    I'd do this in two draw passes.
    The first pass draws the character where it's not occluded (ZTest LEqual) using its original material. The second pass draws the part of the character that is actually occluded (ZTest Greater) using this x-ray kind of material. I think this should do the job.
     
  3. michael-y

    michael-y

    Joined:
    Apr 9, 2013
    Posts:
    18

    Thanks Peter77, That's what I think too, two passes with ZTest accomplish the trick