I’m working on a custom shader that acts as a window, where it hides everything behind it leaving only the skybox. I’m using the BuiltIn pipeline
Here’s the shader:
Shader "Custom/Occlusion"
{
SubShader
{
Tags
{
"RenderType" = "Opaque"
"Queue" = "Geometry-1"
}
Pass
{
ColorMask 0
ZWrite on
ZTest always
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 pos : SV_POSITION;
};
v2f vert(appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
half4 frag(v2f i) : COLOR
{
return half4(1,1,0,1);
}
ENDCG
}
}
}
(I’m not too well-versed on shaders, so please let me know if I’m making any mistakes or could write something better. I appreciate it!)
The issue is that it works perfectly in the scene view, but is black in the gameview. In playmode (in gameview), the shader has this weird visual effect where it seems to duplicate the view as the camera moves or when objects move in front of it. See the second and third gifs for reference
Top/Scene View is what it should look like
Visual effect happening in gameview
It should be showing just the skybox
I don’t understand why it’s working in the scene view but not in the game view.
Let me know if you need any more details, I’d be happy to provide them. Thanks for your time!