Search Unity

Question Unity makes long building time and recompiles shaders while switching between platforms

Discussion in 'Editor & General Support' started by sachaamm, Mar 20, 2023.

  1. sachaamm

    sachaamm

    Joined:
    Apr 11, 2016
    Posts:
    40
    Unity ( 2021.3.11f1 ) makes long building time and recompiles shaders while switching platform ( back and forth from Standalone Windows to Linux Dedicated Server ), around 30 minutes per Build because the editor is compiling all variants shaders from the project, which contains graphical assets dependencies. Usually editor caches shaders for the same building platform but because i switch between these 2 differents building platform shader cache is erased, causing very long deployment time. what can i do ? i thought to duplicate my project with a specific one for each building platform, but it's really not ideal solution...
    I noticed that all shaders are recompiled only when i switch back to Dedicated Server Linux, Windows still have the shader cache but Linux always recompile. this is pretty annoying because:
    - I don't understand why Dedicated Server needs to compile shaders, dedicated server is basically a console application
    - I don't understand how to simply remove all shaders from build. I ordered Shader Control from the Asset Store, but again it seems to work only with Windows Standalone.
     
    Last edited: Mar 21, 2023
    Michael4545 likes this.
  2. alexgg101

    alexgg101

    Joined:
    May 3, 2022
    Posts:
    12
    Any solution to this ?
    I have same problem, switching between a Windows Client Build , and Linux Dedicated Server (now i am using Unity GS Hosting).
    Both builds take ages to compile shaders again after switching between platforms.
     
    Michael4545 likes this.
  3. sachaamm

    sachaamm

    Joined:
    Apr 11, 2016
    Posts:
    40
    i have to mention that i was using URP, upgrading the Unity version of my project since an older version ( Unity 2019 , BuiltIn Render pipeline ). My solution was to restart a new project in Unity 2021.3.20, but using BuiltIn RenderPipeline, reimporting all third party dependencies. Then, when the project was stable and i recovered all features of my game, I switched back to URP and currently I don't get this problem anymore. I think my previous project was corrupted, including a massive amount of Shader variants due to some assets. You can also use https://assetstore.unity.com/packages/vfx/shaders/shader-control-74817 Shader Control to get an overview of shader variants usage in your project to identify assets that might be responsible of a very long building time regarding shader compiling.
     
    Michael4545 likes this.
  4. alexgg101

    alexgg101

    Joined:
    May 3, 2022
    Posts:
    12
    i'm working in HDRP , 2022lts
    my problem appears to have subsided now, after another switch and build, or two,
    still a long time switching between windows and linux, similar to then switching client to dedicated ,
    but not too drastically (~hours) long to build, seems more like normal now.
    must be caching for both .
     
    Michael4545 likes this.
  5. alexgg101

    alexgg101

    Joined:
    May 3, 2022
    Posts:
    12
    this still a bit flakey actually , can't quite put my finger on what what order is happening,
    yesterday seemed ok switching between builds
    today switch back to windows from linux , switch dedicated server to client >> hour long build time
     
    Michael4545 likes this.