Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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:
    11
    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:
    3,046
    Which graphics API are you running this on?
     
  3. nightdriveinteractive

    nightdriveinteractive

    Joined:
    Jul 10, 2023
    Posts:
    11
    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:
    3,046
    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 :)