In GLSL shaders, I often want several functions to change the same value for various reasons (for example, a fragment shader that uses four functions to apply lighting, texture, mirrors and fog, say). I can think of at least three ways to bypass such values ββfor modification:
- Use
inout
for each function. - Pass the value as an in parameter and use the return value (which has the obvious drawback that I can only use one value).
- Use a global variable that modifies each function.
Should I expect any practical differences between these methods? Rather, faster than others? Are some more compatible than others? Are there any other differences? Or other methods, for that matter?
Or can I just choose the one I like best, stylistically?
source share