- Home /
ShaderLab: Adding functions.
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.
Answer by tanoshimi · Sep 05, 2013 at 07:39 AM
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
Your answer
Follow this Question
Related Questions
Disabling a Pass or Subshader Programmatically 0 Answers
Curve shader with lights 0 Answers
In ShaderLab, how could you get the colour of the texture you're rendering to? 0 Answers
Use texture to determine shading? 0 Answers
Two shaders for one model 3 Answers