- Home /
How Can I Avoid Full Shader Recompilation?
I've decided to move some common features from our shaders into some cginc headers to avoid duplication. Whenever I make a change to any include file that has been included by any shader, every single shader in the project gets recompiled (this takes ~5 minutes). The problem is compounded by the difficulty to figure out what compile errors mean and fixing one triggering another. I've started simply creating all the functionality for a cginc file in the shader it will be used in, then moving it the cginc file to only incur the long compile time once (hopefully).
Is there any way to avoid this or any better approach to avoiding code duplication in shaders? It only happens if I actually #include the cginc file in a shader in the project (just having a cginc file in the project hierarchy somewhere doesn't trigger a recompile).
As a side note, modifying a shader that has included one of these custom cginc files does not trigger a recompile of anything except for the individual shader I'm modifying.
Bump...this is very confusing. When does Unity recompile shaders?
@stevesan, ins$$anonymous$$d of posting a useless comment, it would be more beneficial if you actually up-voted the question. The more votes a question has, the higher the likelihood of it being seen. If you just post "bump" type comment, you're not really helping.
Your answer
