- Home /
shaders working in scene view but not in game view [2D]
I have two objects:
1. a meshgrid with a 'mask' shader
2. a black square with a 'HideBehindMask' shader.
The black square is only rendered outside of the meshgrid, which works fine, untill I move to far from the point where I started the game. Then it still shows correctly in the scene view, but not in the game view. Interestingly, this distance also depends on the size of the camera.
I am not sure what could cause the discrepancy between scene view and game view, and especially why it matters how far from the initial starting position I am. Any ideas?
The shader codes:
Shader "Unlit/Mask"
{
Properties
{
_MainTex ("Texture", 2D) = "black" {}
}
SubShader
{
Tags {"Queue"="Geometry-1" }
ColorMask 0
ZWrite Off
LOD 100
Stencil {
Ref 1
Comp always
Pass replace
}
Pass
{
}
}
}
And for the black square:
Shader "Unlit/HideBehindMask"
{
Properties
{
_MainTex ("Texture", 2D) = "black" {}
}
SubShader
{
Tags {"Queue" = "Geometry" }
LOD 100
Stencil{
Ref 1
Comp notequal
Pass keep
}
Pass
{
}
}
}
Thank you for reading and any help :), have a great day!
shader-problem.gif
(521.2 kB)
Comment