I have a shader with many different shader_features keywords. It works fine in the editor, but unless I change them to multi_compile, they don’t work in the build.
I’ve tried using the Frame Debugger in the editor and on the build, and I can see that my keywords are missing in the build (but are present in the editor).
These are not dynamic keywords enabled via C#, they are set on the material at build time.
I’ve tried disabling “Strip Unused Variants” and also tried preloading a shader variant collection that includes the desired shader variants - neither of these seem to work.
Changing them to multi_compile introduces excessive build times, so that isn’t a good option. The shader_feature keywords seem to be working for other shaders in my build. Does anyone know what else could be causing this issue? Is there something I might be missing?
Through trial and error, I discovered that “Strip Unused Post Processing Variants” was the cause of this behavior. Although this isn’t a post-processing shader, it does use the keyword “_DISTORTION” which leads the stripper to believe this is an unused post-processing variant.
Renaming my keyword solved the issue!
This is a pretty unique edge case, but a fix might involve checking the shader name in ShaderPreprocessor.StripVolumeFeatures() before stripping to prevent this from happening to anyone else.
Same problem in Unity 2022.3.10f1 LTS with URP. Can’t update to the higher version of the LTS since those are very broken at the moment. This happens with the shader graph shaders, which is even more bizarre.