Import a file from the shader library in the Built-In Render Pipeline
Import files that contain helper functions and macros, such as UnityCG.cginc and HLSLSupport.cginc.
Read time 1 minuteLast updated 2 months ago
Unity contains several files that can be used by your shader programs to bring in predefined variables and helper functions. This is done by the standard directive, e.g.:
#includeSubShader { Pass { HLSLPROGRAM #include "UnityCG.cginc" ENDHLSL }}
Shader include files in Unity are with extension, and the built-in ones are:
.cginc- : Declares various preprocessor macros to aid in multi-platform shader development. Unity automatically includes this file if you use
HLSLSupport.cginc. For more information, refer to Shader code blocks in ShaderLab reference.CGPROGRAM - : Declares various built-in global variables that are commonly used in shaders. Unity automatically includes this file if you use
UnityShaderVariables.cginc. For more information, refer to Shader code blocks in ShaderLab reference.CGPROGRAM - : Commonly used built-in helper functions and data structures.
UnityCG.cginc - : Lighting and shadowing functionality, for example surface shaders use this file internally.
AutoLight.cginc - : Standard surface shader lighting models. Unity automatically includes this file if your write surface shaders.
Lighting.cginc - : Helper functions for terrain and vegetation shaders.
TerrainEngine.cginc
These files are found inside Unity application ({unity install path}/Data/Resources/CGIncludes/UnityCG.cginc on Windows, /Applications/Unity/Unity.app/Contents/Resources/CGIncludes/UnityCG.cginc on Mac), if you want to take a look at what exactly is done in any of the helper code.