Resources

Unity include files

Unity uses a variety of include files, typically all loaded by the high level UnityCG.cginc file.

These files are distributed with the editor and located in different folders depending on platform.

  • OSX: /Applications/Unity/Unity.app/Contents/CGIncludes/

  • Windows: <Program Files>/Unity/Editor/Data/CGIncludes/

The source for all built-in shaders can be found at https://unity3d.com/get-unity/download/archive, under 'Built in shaders' on the download menu for each release version.

Look at these files in detail for more information, however, some common elements you may see are:

from UnityCG.cginc:

struct appdata_base {
  float4 vertex : POSITION;
  float3 normal : NORMAL;
  float4 texcoord : TEXCOORD0;
};

struct appdata_tan {
  float4 vertex : POSITION;
  float4 tangent : TANGENT;
  float3 normal : NORMAL;
  float4 texcoord : TEXCOORD0;
};

struct appdata_full {
  float4 vertex : POSITION;
  float4 tangent : TANGENT;
  float3 normal : NORMAL;
  float4 texcoord : TEXCOORD0;
  float4 texcoord1 : TEXCOORD1;
  float4 texcoord2 : TEXCOORD2;
  float4 texcoord3 : TEXCOORD3;
#if defined(SHADER_API_XBOX360)
  half4 texcoord4 : TEXCOORD4;
  half4 texcoord5 : TEXCOORD5;
#endif
  fixed4 color : COLOR;
};

and from Lighting.cginc:

struct SurfaceOutput {
  fixed3 Albedo;
  fixed3 Normal;
  fixed3 Emission;
  half Specular;
  fixed Gloss;
  fixed Alpha;
};

Note specifically the second definition which is used by material shaders.