in
/out
for function parameters
From the Parameters
section in the Khronos wiki:
void MyFunction(in float inputValue, out int outputValue, inout float inAndOutValue);
Functions in GLSL use a calling convention called "value-return." This means that values passed to functions are copied into parameters when the function is called, and outputs are copied out when the function returns.
The
in
,out
, andinout
qualifiers are not the same as type qualifiers, even though some of them are named the same. These are parameter qualifiers, and they have a different meaning here.A parameter declared as
in
means that the value given to that parameter will be copied into the parameter when the function is called. The function may then modify that parameter as they see fit, but those changes will not affect the calling code.A parameter declared as
out
will not have its value initialized by the caller. The function will modify the parameter, and after the function's execution is complete, the value of the parameter will be copied out into the variable that the user specified when calling the function. Note that the initial value of the parameter at the start of the function being called is undefined, just as if one had simply created a local variable.The
inout
declaration combines both. The parameter's value will be initialized by the value supplied by the user, and its final value will be outputThe default if no qualifier is specific is
in
.