UsePass - what exactly does it do?

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

Hi!
Can you please submit a bug report? UsePass should just do that - take a pass from another shader.
Thank you!

Hi @ElliotB ,

sorry it took so long - the problem lies with local keyword handling. If you remove the “_local” suffix in the outline shader pass, everything works just fine.

Cheers,
Aleks

1 Like

Thanks very much for the reply!

We use " UsePass “Universal Render Pipeline/Lit/Meta” " in our custom shader and after building in iOS the xcode warns the shader is not supported on this gpu.
However, if we use the whole pass that copied from the shader file, it will succeed to run in iOS without any warnings.
So this issue caused by “_local” suffix?