Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Easy way to clear compiled shaders for player build?

Discussion in 'General Graphics' started by nightdriveinteractive, Aug 23, 2023.

  1. nightdriveinteractive

    nightdriveinteractive

    Joined:
    Jul 10, 2023
    Posts:
    7
    I'm trying to debug a shader compile hitch in my game. I'm prewarming all my shaders, so there must be some rogue shader(s) that I missed during the prewarm phase.

    Is there a simple way to clear the compiled shaders for a player build? One which doesn't involve running the build on a new PC, reinstalling graphics drivers, etc.?

    I'm going to use "Log Shader Compilation" after to catch the shader that causes the hitch--in theory. I haven't actually used it before; looks like it's a solution though.
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
    Which graphics API are you running this on?
     
  3. nightdriveinteractive

    nightdriveinteractive

    Joined:
    Jul 10, 2023
    Posts:
    7
    Windows 10 - DirectX 11 and 12.

    I was deleting the shader cache in the project folder in order to reproduce the problem in the editor; it could be time-consuming compiling every shader again though.

    I managed to figure out what was causing the hitch: post-processing shaders. I have an exorbitant amount of custom post effects.

    My fix is to activate the player camera a little bit before the load screen is removed. Everything is smooth as silk now.
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,890
    I not sure how removing the compiled variant cache could've helped you here. Yes, it can be time-consuming, that's why we have the cache in the first place :)