November 2019
Intermediate to advanced
404 pages
12h 9m
English
The shader compiler often performs a good job of reducing mathematical calculations down to an optimized version for the GPU, but compiled custom code is unlikely to be as effective as both the Cg library's built-in helper functions and the additional helpers provided by the Unity Cg included files. If we are using shaders that include custom function code, perhaps we can find an equivalent helper function within the Cg or Unity libraries that can do a better job than our custom code can.
These extra include files can be added to our shader within the CGPROGRAM block, as follows:
CGPROGRAM// other includes#include "UnityCG.cginc"// Shader code hereENDCG
Example Cg library functions to use are abs() for ...
Read now
Unlock full access