Well guess the title says it all no matter what shader I have in the Assets folder if includes a custom *.cginc it will fail to compile. Funny thing is that I’m having this error with shaders of both PostProcessingStack and TextMesh Pro packages.
Make sure your shader file if it includes other files has the right folder structure. I ran into this also after I moved my files around into different folders. It is basically breaking the connection between the custom files.
IE: In my shader file I include a resource file. I used to just have it here in the root like this.
#include “/CustomShaderFile.cginc”
So when I moved my custom shader into a new folder I had to change the structure so it looked in the right folder. #include “…/ShadersFolder/CustomShaderFile.cginc”
Also, if you re-named the .cginc file and you know the path of to the include is correct in your shader, try closing Unity and re-opening the project. That fixed my issue.
Same bug still in 2019.2+ - if you reference a custom .cginc file and move either the .cginc, or the shader, to a new subfolder then you get a bunch of fake errors about missing core CGInc files (which are definitely NOT missing), and the Inspector shows a long list of errors for all the core CGI files that Unity now claims it cannot find (although obviously it can, because they haven’t moved :))
i’d like to say that after 3 times creating new projects and reimporting, my cginc finally worked. I’m not sure what really repairs that. I have even changed the endcoding of that source by notepad++.
hi,
im having this trouble with an #include in a compute shader the line is #include “Assets/FastNoiseLite”
that should work right? im just teaching myself compute shaders and im am getting quite a few weird errors, like it complains that the line RWTexture2D4 texturename is wrong, so i just delete and retype it and now its fine!! i mean really!!! is this just really broken or what?
some code that was working before, i added some more code, it didnt work so i just removed it, and now the the original code isnt working either, even though its exactly the same as it was before…
is anyone else having any trouble just getting basic stuff to work?
If one of the user include fails, it output failure message about built-in also. (Thus those misleading error message about built-in cginc missing, which is outside user’s responsibility)
For example, if you have shader “Assets/Shaders/a.shader” which has CGINCLUDE
and another custom include line that says #include "Extra/ColorUtil.cginc" (expects Assets/Shaders/Extra/ColorUtil.cginc)
and you dont have it. You get complain about built-in also!
I had this issue only after moving a folder. I am on 2020.3.24f1 though and shouldn’t have this issue of losing references when moving folder with shaders. Reimporting did solve it for me too, though.
I have the same problem with ProBuilder.
Shader error in ‘Hidden/ProBuilder/VertexPicker’: Couldn’t open include file ‘ProBuilderCG.cginc’. at line 31
Shader error in ‘Hidden/ProBuilder/EdgePicker’: Couldn’t open include file ‘ProBuilderCG.cginc’. at line 29
If i change line #include “ProBuilderCG.cginc”
to #include “…/Shader/ProBuilderCG.cginc”
error disappear, but then warning says:
The package cache was invalidated and rebuilt because the following immutable asset(s) were unexpectedly altered:
Packages/com.unity.probuilder/Content/Shader/VertexPicker.shader
The package cache was invalidated and rebuilt because the following immutable asset(s) were unexpectedly altered:
Packages/com.unity.probuilder/Content/Shader/VertexPicker.shader
and its return to #include “ProBuilderCG.cginc”
Re-import doesn’t help. It looks like a bug.
Only helps to move ProBuilderCG.cginc to {unity install path}/Data/CGIncludes/ but its very bad solution to move custom file from package to Built-in shader files folder.
i had the same problem, but in editor it didnt matter, as i was not using the shaders (where in a unused package) i could start “play” mode.
but build failed (some times! not always), and then REIMPORT did not help me.
what did help me IN EDITOR, was deleting .meta files (in a folder with many shaders),
but didnt work in a folder with few shaders.
but when building the errors came back
BUT what helped finally was editing the shader files that did #include “filename.cginc” which referenced correct cginc files placed in same folder(s) as shader(s) to become #include “./filename.cginc”