Simple question:
In GLSL, is there a way to share functions across multiple shaders, or do I have to define all functions in every shader that needs them?
|
Simple question: In GLSL, is there a way to share functions across multiple shaders, or do I have to define all functions in every shader that needs them? |
|||
|
|
|
You can define some functions in a header file and #include them into your shader. It's a bit different from C/C++ in that you'd put the bodies of your functions in the headers, not just their prototypes (since shaders have no concept of separate compilation & linking), but other than that it's just like C/C++ headers. |
|||||
|
|
If #include is not available you would use the arguments of glShaderSource to specify the shared stuff. Example:
|
|||
|
|