All about shaders


Inputs/Outputs

Built-in Uniforms

Intrinsic Functions

Coding Guidelines

Convert HLSL to GLSL


Overview

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.

Here is an example on how a Flair shader looks like:

/* 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);
}

Interface

← Shader has one output

← Shader has one uniform input named Color. It is a vec3 type **with a color widget

GLSL

← declaration

← main function that outputs the input color when run

Based on this shader, Flair will:

  1. Identify outputs/inputs
  2. Modify the node interface based on the defined interface
  3. Bind the data to the GLSL program
  4. Run the GLSL program when requested.

<aside> 🤓 To learn more about how to write shaders in Flair, please take a look at the examples under Flair/shaders and refer to the documentation above to the left.

</aside>