Shader Anatomy
Table of contents
While the shaders in the Flair graph are mostly writen in GLSL, one can also define the interface that will be shown in Flair. Therefore, shaders in Flair are divided in two parts, the interface and the shader code.
The shader code of a Flair shader is written in plain GLSL code, whereas the interface is written in TOML and defined within a special /* interface */
comment block.
Example shader code
Here is an example on how a Flair shader looks like with a detailed explanation below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* interface
outputs = ["Output"]
[[uniforms]] # table (dict) within "uniforms"
name = "Color"
type = "vec3"
widget = "color"
*/
uniform vec3 Color;
out vec4 Output;
void main() {
Output = vec4(Color, 1.0);
}
From these shaders, Flair will:
- Identify outputs/inputs
- Modify the node interface based on the defined interface
- Bind the data to the GLSL program
- Run the GLSL program when requested
Many examples of different Flair shaders can be found under Flair/shaders.