June 2018
Intermediate to advanced
392 pages
8h 57m
English
This shader relies on things that have not been introduced before in this book; the first one is arrays. Cg allows arrays that can be created with the following syntax:
uniform float3 _Points [20];
Cg doesn't support arrays with an unknown size: you must preallocate all the space that you need beforehand. The preceding line of code creates an array of 20 elements.
Unity allows us to set arrays through using a number of methods, including SetVectorArray, SetColorArray, SetFloatArray, and GetMatrixArray.