Create an Unity transparent shader that hides itself

2.2k Views Asked by At

My shader code is:

Shader "Custom/Transparent" {
     Properties{
         _Color("Main Color", Color) = (1,1,1,1)
         _MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
     }
     SubShader{
         Tags {"RenderType" = "Transparent" "Queue" = "Transparent" }
         Blend SrcAlpha OneMinusSrcAlpha
         ZTest Always
         Pass {
             ColorMask 0
         }

         UsePass "Transparent/Diffuse/FORWARD"
     }
     Fallback "Transparent/VertexLit"
 }

and I only can get this result: enter image description here

The finger is pointing down: enter image description here

What I really want to achieve is this: enter image description here So the hand is transparent but it does't show itself just the object behind it. What can I do?

EDIT 1: I tried to change "ZWrite" to "On" and restart Unity but it had the same result, the hands are Oculus Hands. The problem in particular is that I have "ZTest Always", when I remove it, it already works but I additionally need that the ghostly hand can be seen between solid objects so I cannot remove that part

1

There are 1 best solutions below

2
Vect0rZ On

To achieve this, you will need to enable depth buffer writing by adjusting the ZWrite option that you have to "Off" as so:

Pass {
         ZWrite On
         ColorMask 0
     }

More reading on the subject you can find here

https://docs.unity3d.com/2020.1/Documentation/Manual/SL-CullAndDepth.html