It is possible to add include files in the shader to make use of Unity predefined variables and helper functions.
You can see the available includes in C:\Program Files
\Unity\Editor\Data\CGIncludes. For example, in the include UnityCG.cginc you can find several useful helper functions
and macros used in many standard shaders. To use them declare the include in your
shader.
A number of Unity builtin variables are available to shaders. They are located
in the include UnityShaderVariables.cginc. You are
not required to include this file in your shader because Unity does this automatically.
Several useful transformation matrices and magnitudes are directly available in the
shaders. It is important to know all of these to avoid duplicating the work. For
example, before considering how to pass a matrix to the shader, camera position or
projection parameters or light parameters, check if an include already provides
this.
To improve performance, it is sometimes preferable to execute an
operation in the CPU and pass the result to the GPU instead of executing it in the
vertex shader for every vertex. For example, this is the case of multiplications of
matrix uniforms. This is the reason why Unity made available for us as builtin uniforms
several compound matrices. Some of the important Unity shader builtin values are shown
in the following table:
Table 61 Important Unity shader builtin values
Builtin Uniform

Description

UNITY_MATRIX_V 
Current view matrix 
UNITY_MATRIX_P 
Current projection matrix 
Object2World 
Current model matrix 
_World2Object 
Inverse of current world matrix 
UNITY_MATRIX_VP 
Current view * projection matrix 
UNITY_MATRIX_MV 
Current model * view matrix 
UNITY_MATRIX_MVP 
Current model * view * projection matrix 
UNITY_MATRIX_IT_MV 
Invert transpose of current model * view
matrix 
_WorldSpaceCameraPos 
Camera position in world space 
_ProjectionParams 
Near and far planes and 1/farPlane as components of a vector 
_Time 
Current time and fractions in a vector (t/20, t,
t*2, t*3) 