Well, you can, but the second one will be ignored and only the first pass will ever be used.
If you want different behaviors for different use use cases (camera depth vs. shadow map depth) then you have to detect which is currently being rendered and change the output.
This method is still the only one I’ve found to work consistently, and it only works if you don’t set your shadow bias to zero.
if (unity_LightShadowBias.z)
{
// do shadow caster specific code
}
else
{
// do camera depth specific code
}
This is actually what Unity’s own shader code does.
The minor modification to that mentioned here is also good if you want to support point light shadows as those disable normal bias (what’s stored in the unity_LightShadowBias.z) and exclusively use unity_LightShadowBias.x (which is depth bias).
if (any(unity_LightShadowBias) == false)
{
// do shadow caster specific code
}
else
{
// do camera depth specific code
}
But both will break if you set the biases to zero. There were other methods that were 100% consistent, but Unity has broken those all (as mentioned in the first post I linked).
Thank you for exhaustive reply.
When i think some more, shadow dithering looks very much what opaque cutout shader does - both do discard/clip. Its just dithered shadows do it at the level of single texels. Sigh … Again, thanks !