I want to make an object invivisble and that blocks vision for things behind it.
The purpose for this is for AR.
For example i want to place eyes that follow the user on a statue. When i am behind the statue i dont want the eyes to be visible through the statue.
I am quite new to shaders and wonder how this can be done.
Thank you for any advice or tips
You want a depth only shader.
Shader "Custom/Depth Only"
{
SubShader {
Pass {
ColorMask 0
ZWrite On
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float4 vert (float4 vertex : POSITION) : SV_POSITION { return UnityObjectToClipPos(vertex); }
void frag() {}
ENDCG
}
}
}
I hadnt had a chance to test it until to day. It worked somewhat.
It doesnt block everything. It seems to work while in scene but not when i build it to my phone.
In the picture there is a cube infront and behind the object with the shader.
NeverMind I got it working.
I changed the render queue and then it worked. (Pic) 1
How it looks (pic2)
Thank you very much for your help Bgolus.
![]()
Hey, I hope you guys might help me, Im using this shader, but in the build, Where it should be transparent Im seing all black, any ideas? Thanks in advance

