Inputs and outputs need to be specified in both, the interface and the GLSL code for Flair shaders to work correctly. Flair shaders are mainly written in plain GLSL, but the interface is defined within the comment block \* interface */ in a simpler language called TOML.
TOML is a minimal markup language (similar to YAML) that makes defining inputs and outputs for the shader easier for artists.
Names in the interface must correlate to names in the shader code for values to bind correctly.
Outputs
There can be multiple Outputs in a Flair shader and they need to be defined through the interface (TOML) and declared in the GLSL code as follows:
One output
1
2
3
# TOML# defines one "Output" for the node outputs = ["Output"]
1
2
3
4
5
// GLSL// declares one output: "Output" outvec4Output;
Multiple outputs
1
2
3
# TOML# defines three outputs for the nodeoutputs = ["Color", "Normals", "Edges"]
1
2
3
4
5
// GLSL// declares three outputsoutvec4Color;outvec4Normals;outvec4Edges;
Inputs
There can be multiple Inputs in a Flair shader of different types, which also need to be defined in the interface and declared in the GLSL code as follows:
Texture Inputs
One input texture
1
2
3
4
5
6
7
# TOML# define a texture input[[textures]]name = "Texture"
1
2
3
4
// GLSL// declare an input textureuniformsampler2DTexture;
Multiple input textures
1
2
3
4
5
6
7
# TOML# define two texture inputs[[textures]]name = "Texture1"[[textures]]name = "Texture2"
1
2
3
4
// GLSL// declare two input texturesuniformsampler2DTexture1;uniformsampler2DTexture2;
// GLSLuniformintInteger;// declare an integer number
Integer vectors
1
2
3
4
# TOML[[uniforms]]name = "IntVector2"# define an integer vector input (parameter)type = "ivec2"# or "ivec3", "ivec4" depending on how many channels are needed
1
2
// GLSLuniformivec2IntVector2;// declare an integer vector (ivec3 or ivec4 respectively)
min: minimum value of the parameter. If nothing is specified, then the parameter has no minimum value.
max: maximum value of the parameter. If nothing is specified, then the parameter has no maximum value.
step: the step size when increasing or decreasing the parameter. If nothing is specified, it will be inferred from the min and max values, or the parameter type (float 0.1, int 1)
For int parameters, one can create check boxes and combo boxes through the widget attribute.