Shader Stripping Broken when using URP Subclass

First off: I am not talking about Shader Compilation taking a long time, or stripping not working.

When I build, some shaders take more than ten minutes to “prepare” the variants:

As you can see in the screenshot, the variants are correctly stripped, and then the remaining variants are retrieved from cache, so it’s not the compilation that takes time.

What is this insane “prepare” step? How can I avoid it? It’s also not something that goes away on a ‘warm’ build, the screenshot is not from the first build.

I tried to reproduce it in a clean project. This is for the same shader (URP/Lit). Here, the preparing step is not long enough to even show in the log & the build is done quickly:

CLEAN PROJECT:

Does anybody have any idea what project settings influence this Prepare/Process step? What’s causing my one project to spend 30 minutes preparing variants, and a clean project does it instantly?

Okay, found the source:

I was using a custom subclass of UniversalRenderPipelineAsset to be able to replace the grass shader.

Doing that prevents Unity from properly stripping shader variants somehow:

See this thread: 2019.2: Overriding shaders of Terrain-Grass page-3#post-9835866

I made a bug report, IN-76325, because I think that variant prefiltering should actually just work in this scenario…

There’s nothing that makes my extended URPAsset different from the regular URPAsset in regards to shader variants.

3 Likes