SixWays / UnityShaderStripper

Modular utilities for shader stripping to drastically improve Unity build times
MIT License
350 stars 42 forks source link

Does this work in URP 2021.2 ? #9

Closed SpikeborOfficial closed 2 years ago

SpikeborOfficial commented 2 years ago

Using Variant Collection which I collect using prewarming current scene, and in build I only build that scene, so my guess is those shaders are all I need to include. The build time cut by 7/8 ( 8 hours to 1 hour ) which is nice, but everything is pink.

SpikeborOfficial commented 2 years ago

Also I did write in Strip by name, start with Hidden/Universal Render Pipeline/Terrain which I double check many time with no typo, but I still see it's families being compiling on build.

SixWays commented 2 years ago

Strip By Variant Collection is the most unpredictable unfortunately - Unity doesn't seem to make a very accurate list of what shaders are actually in use. As such it should only be used for quick builds where you don't care much about shaders.

PolyTimotheos commented 2 years ago

From my testing i think that UnityShaderStripper doesn't handle the new local macros for variants at all really. So if you have #pragma shader_feature_local / #pragma shader_feature_local_fragment (and others) in your shaders, you're bound to have some pink materials.

@SixWays Did you notice this as well ? Is this something you are likely to fix ?

I've been using your tool for about 2 years and it's been a godsend <3 , builds now only take 3 - 8 minutes whereas they took about an hour before. Massive improvement to iteration Times! Unity should pay you a million and integrate that thing into their engine.

Also i think shadervariant stripping is pretty useable, you just gotta be careful with your shaders and materials but it works for my case.

SixWays commented 2 years ago

I've not used it with those pragmas so can't say! But not too surprising. I can't promise to take a look any time soon - it basically depends on whether I'm using it for a particular thing. Good to hear it's been of use to you though!

SpikeborOfficial commented 2 years ago

It's sad that on user's perspective, the variants that be warmed up while user playing the level should be all the variants the build need for that level. But Unity failed to deliver that, at this point I don't think the variant collection asset have any use. I warmed up the level, collect the variants to asset, set the asset as preloaded shaders. Notice the Tree LOD Instancing_ON is there in the variant asset, yet in build player log I see Unity complained that the Tree LOD Instancing_ON is missing. Which does not make any sense. I honestly think this is a bug, for when I'm about to release my game I'll file this as a bug report.