Ghost-Transparent Shader for multiple-mesh character ?

Hello,

I have a character made of several meshes (1 for body, 1 for armor, etc…)
So I cannot use the trick exposed here : file:///D:/Unity5/Editor/Data/Documentation/en/Manual/SL-CullAndDepth.html ; the different meshes are still flickering visible/not visible when turning around the character.

I tried to do a multipass shader, but it seems a shader can have only 1 queue. Is there any other way to achieve that ?

Here my current shader :

Shader "Legacy Shaders/Transparent/Bumped Specular (Too)"
{
   Properties
   {
     _Color ("Main Color", Color) = (1,1,1,1)
     _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0)
     _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
     _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {}
     _BumpMap ("Normalmap", 2D) = "bump" {}
   }

   SubShader
   {
     LOD 400

     // extra pass that renders to depth buffer only
     Pass
     {
       Tags { "RenderType"="Opaque" }

       ZWrite On
       ColorMask 0
     }

     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}

     Offset -1, -1
     ColorMask RGBA
     ZWrite Off
     ZTest LEqual

     CGPROGRAM
       #pragma surface surf BlinnPhong alpha:blend
       #pragma target 3.0

       sampler2D _MainTex;
       sampler2D _BumpMap;
       fixed4 _Color;
       half _Shininess;

       struct Input
       {
         float2 uv_MainTex;
         float2 uv_BumpMap;
       };

       void surf (Input IN, inout SurfaceOutput o)
       {
         fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
         o.Albedo = tex.rgb * _Color.rgb;
         o.Gloss = tex.a;
         o.Alpha = _Color.a;
         o.Specular = _Shininess;
         o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
       }
     ENDCG
   }

   FallBack "Legacy Shaders/Transparent/VertexLit"
}

The only solution left is to get 2 different characters, 1 with the “write only to Z-buffer” shader, and the other one with the actual transparent rendering.
But I’m a bit afraid it’ll get some issue with animation sync between the 2… (at least my code right now can’t handle that, and it’s not too easy to change it)

Thanks in advance for any help !

Ok, I cloned my character, assigned the same material to all parts of the clone ; that material uses the Write-Only-To-Zbuffer shader.
I then copied on Start() the controller from the original character’s animator to the cloned one, and it works nicely…! :slight_smile:

Shader "Effects/WriteOnlyToZBuffer"
{
    SubShader
    {
        LOD 400
        Tags { "RenderType"="Opaque" }

        // renders to depth buffer only
        Pass
        {
            ZWrite On
            ColorMask 0
        }
    }

    FallBack "Legacy Shaders/Transparent/VertexLit"
}