Why Unity compiles shadres for dedicated server (no graphics) build? Maybe it should be disabled?

Unity 2021.3.21f1 HDRP
Shader variants compilation takes a lot of time, would be better to skip them for the console build.
If it is possible.

1 Like

I also have been wondering how to skip shader variants compilation for dedicated server build! Can someone enlighten us please

How do we tag Unity Team on this issue??? I am not intentionally loading any shaders on server side but yet my dedicated linux server build with no graphics also does the same, trying to load shaders.

i though Unity Dedicate Server build was suppose to strip shaders by default?

Hi all!
In Unity 2021.3 you'd need to use the IPreprocessShaders to strip shaders when building for Dedicated Server.
In Unity +2022.3 we have an Enable Dedicated Server Optimizations option (PlayerSettings.dedicatedServerOptimizations), enabling it will strip all shaders from the build.


Thanks soo much!!! This is very helpful!

@cristianm_unity Is there an API for enabling this in a build script?

EDIT: I'm on 2022.3.2f1 and can't find it in any way, not even in the Player Settings window. Was this added later on?

https://docs.unity3d.com/ScriptReference/PlayerSettings-dedicatedServerOptimizations.html should work, does it not?

Indeed, it was added recently to 2022.3. So I’d recommend trying it in the latest 22 LTS.

I have enabled the Dedicated Server Optimizations option and my server build still compiles shaders and taking forever to build. Am I missing something?

@andre_6865 , usually enabling the option should be enough. I can have a look, what can you tell me about your project? Editor version, render pipeline, type of shaders.

Or even better, if you could create a bug report where you can attach a repro project that'd help us a lot.

I have the same issue. When I run the server, I get warnings about shaders. I use Unity 2022.3.10, URP, and Entity graphics. I just have updated Unity to 22.3.20, but Unity compiles shaders anyway, and I think there will be in the build, too.

can confirm that we have the same issue as alexandr