Search Unity

Cloaking, Dissolve into Refraction

Discussion in 'Shaders' started by SMD-Indomitable, Jul 5, 2020.

  1. SMD-Indomitable

    SMD-Indomitable

    Joined:
    Mar 21, 2016
    Posts:
    9
    Can anyone explained how this would work. I am still learning shader, and I am confuse as to how Refraction will work together with Opacity Clip. The video below is what I want to achieve on the shader. Could anyone point me in the direction that I should be looking.

     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    This is using a three pass transparent shader with a grab pass.

    Pass 1: Grab Pass
    Pass 2: ZWrite Only Pass
    Pass 3: Refraction, Cloak Transition & Opaque Lit Pass

    The trick is there's no opacity clipping / alpha testing. It's a transparent shader that's using an opaque blend mode and blending between the refraction color, the transition glow, and the "opaque" surface.

    The refraction is sampling the grab pass texture distorted by the ship's view space normals. You can find examples of that around. The ZWrite Only pass you can find examples of around, including in Unity's own documentation. Then you can find any opacity clip / dissolve shader out there and instead of using the dissolve alpha as the shader's alpha output, you use it to drive a lerp.

    Something like this:
    fixed4 col = lerp(refraction, lit, saturate(dissolveAlpha - _Dissolve));
     
    SMD-Indomitable likes this.
  3. SMD-Indomitable

    SMD-Indomitable

    Joined:
    Mar 21, 2016
    Posts:
    9
    Thank you so much!