- Home /
Character behind obstacles shader, multiple Pass issue
Hi,
I'm starting my adventure with shaders, and having limited knowledge I don't know where else to look for the solution. My goal was to have a simple shader that renders an object just with color, but if the object is hidden behind other objects, use another color (so that a character position is known even if behind an obstacle). This is what I wrote:
Shader "Custom/TestShader"
{
Properties
{
_Color1 ("Color1", Color) = (1,1,1,1)
_Color2 ("Color2", Color) = (1,1,1,1)
}
SubShader
{
Tags { "Queue" = "Overlay" }
Pass
{
ZWrite Off
ZTest Greater
Lighting Off
Color [_Color1]
}
Pass
{
ZTest Less
Color [_Color2]
}
}
}
The problem is that the only first Pass
block seems to be working. If I switch the Pass
blocks order, still only the first one seems to be working but the other one is not. Here's whats happening with Pass
blocks in different order:
I'm using URP. Can someone point me to the right direction with this? Why is only the first block working? Is there something obvious I'm missing?
screenshot-2022-05-16-at-173453.png
(41.6 kB)
screenshot-2022-05-16-at-173551.png
(41.5 kB)
Comment