This reference book "Unity Shaders and Effects CookBook".
First of all, the simple Shader Cheap Shader, lightweight Shader is mainly memory consumption, map usage, and data usage to optimize.
The following is a detailed talk about those optimizations 1. Change variable type (reduce memory)
First of all, a few variable types: float:32 bit floating point data, corresponding to the value of FLOAT2,FLOAT3,FLOAT4, the following data represents an array, such as FLOAT2 (1.0f,1.0f) half:16 bit floating point data, using and storing UV values, color values, is much faster than using the float value, the corresponding value has HALF2,HALF3,HALF4 fixed:12 bit fixed-point number, used for the calculation of light color, the corresponding value is fixed2,fixed3,fixed4.
Here are some examples of two types of changes:
One: Change the UV value type, changed from float to half
Before the change:
After the change:
Second: Change the value type in the light color calculation
Light calculation:
Color calculation:
2. Turn off render additional channels (reduce lights Shader process) or specify rendering directly
To turn off rendering additional channels:
Specify rendering:
Similar to the following:
3. Sharing Uvs (sharing UVS)
Remove the input from the normal map and use Unpcknormal to share the Uvs.
4. Control based on Unity's own performance Analyzer