Opaque forward render pass renders shaders that are defined as incompatible w/URP

Hi,

Consider the following Subshader

SubShader
        {
            Tags { "RenderType" = "Opaque" "RenderPipeline" = "NotAStandardPipeline" }

The documentation reads:
The RenderPipeline tag tells Unity whether a SubShader is compatible with the Universal Render Pipeline (URP) or the High Definition Render Pipeline (HDRP).

The parameter value ‘(any other value, or not declared)’ indicates ‘This SubShader is not compatible with URP or HDRP.

However, the Opaque Forward Renderer pass (and maybe others) ignores this when using the ForwardRenderer, and will draw all shaders regardless of render pipeline setting. Is this working as intended and the manual needs updating, or a bug?

Cheers,
Elliot

Hi!
Sounds like a bug to me :slight_smile:
Please report it.
Thanks!

1 Like

Hi aleks, do you happen to know at what stage the RenderPipeline tag is actually used? I can only find a handful of references to it in the unity graphics repo, and none seem to really explain why it should lead to exclusion of shaders from build (current behavior on 2022.3 - possibly due to a fix?)

That leads me to believe the tag is nothing to do with rendering logic, but possibly used when stripping during building (that would also explain why an incorrect tag still works in editor, but not in build, as per this post: https://discussions.unity.com/t/925179 )

Cheers,
Elliot

Hi Elliot,

It is used in the rendering logic in the engine itself.
Looks like the pipeline is checked in ShaderPreprocessor.cs in the SRP Core package and variants are stripped based on this value.

Cheers,
Aleks

1 Like