Hi,
I always thought that UsePass was more or less equivalent to copy/pasting the pass from another shader.
For instance, if I define:
SubShader
{
Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline" }
UsePass "Unlit/SomeShader/UNIVERSAL FORWARD"
}
then this would take the UNIVERSAL FORWARD pass from Unlit/SomeShader and place it into the current shader.
However, I’m now seeing an inconsistent behavior when building. I have a shader defined like so:
SubShader
{
Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline" }
UsePass "Shaders/SomeShader/UNIVERSAL FORWARD"
UsePass "Shaders/SomeShader/SHADOWCASTER"
UsePass "Shaders/SomeShader/DEPTHONLY"
UsePass "Shaders/SomeOtherShader/OUTLINEPASS"
}
where the ‘OUTLINEPASS’ is a pass with a LightMode=Outlines that I use for doing per-object outlines and some other stuff in a separate URP render feature.
Everything works completely fine in editor, scene view + game view. If I build in 2019.4.23f1, URP 7.5.3, then things do not work:
- If I define the pass from SomeOtherShader first, the material does not take the passes from SomeShader.
- If I define the SomeShader passes first, the material does not take the pass from SomeOtherShader.
- If I copy and paste the OutlinePass from SomeOtherShader and define it through Pass {}, the entire shader works perfectly with all passes included in both build and editor.
So with that in mind - what exactly does UsePass do? How does it differ from defining a pass inside the shader? What causes the above behaviour where it works for Pass {} defined in the shader, but not with UsePass for builds only.
Cheers,
Elliot