Hello everyone.
I have a question about how to create my own functions in Shadelab? I have a repeated block of instructions and I want to put them in a function.
Thanks a lot.
Hello everyone.
I have a question about how to create my own functions in Shadelab? I have a repeated block of instructions and I want to put them in a function.
Thanks a lot.
You create functions in CG exactly the same as you would in C, e.g.:
float FuncThatReturnsAFloat() { return float(1.0); }
The vert, frag, and surf programs that you’ll find in any of Unity’s standard shaders are all examples of functions - just add your own into the CG code and call them when required. You can find the full CG reference at http://http.developer.nvidia.com/Cg/Cg_language.html