Unity 2021 refuses to recompile shader when .cginclude file is changed

Hello,

Recently I’ve had an issue where Unity will not automatically recompile a shader when I edit a .cginc file that is part of this shader.

Even if I manually reimport the shader file, and see the cyan color showing that the shader is recompiling, the shader does not track the changes I made to the .cginc file unless I also make some unrelated C# code change, at which point the changes do get recompiled into the shader … but only once.

Has anyone else experienced this and know of a fix? Thanks.

EDIT: Originally I had said “.cginclude” instead of “.cginc.” That was only a typo in the thread, not in the project! My mistake.

Hi!
I think the issue is that “.cginclude” is not a valid shader include file extension
You should use “.cginc” or “.hlsl”.

Sorry, that was just off the top of my head. The extension is “.cginc”

No worries :slight_smile:
How exactly is it included? Is it guarded by any preprocessor conditionals?
There’s a know bug where include dependencies are not gathered correctly if the include is behind something like this:

#pragma multi_compile KW_A KW_B
#if KW_A
#define FOO 1
#endif

#if FOO
#include "myInclude.cginc"
#endif

Yep, that’s almost certainly what it is. Glad to know you’re aware of that! Thanks.