Built-in shader include files 内置的材质包含文件
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 #include
directive, e.g.:
Unity包含几个文件,这些文件可以被你的着色程序用来引入预先定义的变量和帮助函数。这是由标准的include指令完成的,例如:
CGPROGRAM
// ...
#include "UnityCG.cginc"
// ...
ENDCG
Shader include files in Unity are with .cginc
extension, and the built-in ones are:
Shader包括了unity的文件。cginc的扩展,内置的是:
-
HLSLSupport.cginc
- (automatically included) Helper macros and definitions for cross-platform shader compilation. - (自动包含)帮助器宏和跨平台着色编译的定义。
-
UnityShaderVariables.cginc
- (automatically included) Commonly used global variables. - (自动包含)常用的全局变量。
-
UnityCG.cginc
- commonly used helper functions. - 常用的辅助函数。
-
AutoLight.cginc
- lighting & shadowing functionality, e.g. surface shaders use this file internally. - 照明和阴影功能,如表面着色器在内部使用这个文件。
-
Lighting.cginc
- standard surface shader lighting models; automatically included when you’re writing surface shaders. -
TerrainEngine.cginc
- helper functions for Terrain & Vegetation shaders. - 标准的表面着色照明模型;当你书写表面着色时,自动包括。 TerrainEngine。cginc-辅助功能,用于地形和植被的着色。
These files are found inside Unity application ({unity install path}/Data/CGIncludes/UnityCG.cginc on Windows,/Applications/Unity/Unity.app/Contents/CGIncludes/UnityCG.cginc on Mac), if you want to take a look at what exactly is done in any of the helper code.
这些文件在里面统一应用程序({统一安装路径} /数据/ CGIncludes / UnityCG。cginc在Windows上,/应用程序/ / Unity.app /内容/ CGIncludes / UnityCG统一。在Mac上的cginc),如果你想看看在任何辅助代码中都做了什么。
HLSLSupport.cginc
This file is automatically included when compiling CGPROGRAM shaders (but not included for HLSLPROGRAM ones). It declares various preprocessor macros to aid in multi-platform shader development.
在编译CGPROGRAM着色器时,这个文件会自动被包含(但是对于HLSLPROGRAM的文件不包括在内)。它声明了各种预处理器宏来支持多平台的着色开发。
UnityShaderVariables.cginc
This file is automatically included when compiling CGPROGRAM shaders (but not included for HLSLPROGRAM ones). It declares various built-in global variables that are commonly used in shaders.
在编译CGPROGRAM着色器时,这个文件会自动被包含(但是对于HLSLPROGRAM的文件不包括在内)。它声明了在着色器中常用的各种内置全局变量。
UnityCG.cginc
This file is often included in Unity shaders. It declares many built-in helper functions and data structures.
这个文件通常包含在统一着色。它宣布许多内置的辅助函数和数据结构。
Data structures in UnityCG.cginc 数据结构在UnityCG.cginc
- struct
appdata_base
: vertex shader input with position, normal, one texture coordinate. - struct
appdata_tan
: vertex shader input with position, normal, tangent, one texture coordinate. - struct
appdata_full
: vertex shader input with position, normal, tangent, vertex color and two texture coordinates. - struct
appdata_img
: vertex shader input with position and one texture coordinate.