Primitive types
Types
Now that you know how to write a basic node, you might wonder what all the possibilities are. Here are the types you will use most often as inputs and outputs of your main function:
UV: The 2D coordinates that we use to sample our images. (vec2under the hood).float: Just a regular number.SignedDistance: A distance to an object, used for SDF rendering. (floatunder the hood).- Color (
Oklab,sRGB,LinearRGBorOkhsl). See the Color Spaces section to learn all about the various color types. (vec3under the hood). - Color and alpha. (
Oklab_PremultipliedA,Oklab_StraightA,LinearRGB_PremultipliedA,LinearRGB_StraightA,sRGB_PremultipliedA,sRGB_StraightA,Okhsl_PremultipliedAorOkhsl_StraightA). See the Color Spaces section to learn all about the various color types. (vec4under the hood).
And here are all the remaining types, that are seldom used:
boolintvec2vec3vec4mat2mat3mat4Angle(floatunder the hood).Hue(floatunder the hood).Direction2D(vec2under the hood, guaranteed to be of length 1).
info
It is important to note that these types are purely semantic, and in your code you can just treat them as a regular int / float / vec2 / vec3 / vec4.
Examples
Here are a few examples of typical main functions you might define:
Color Transformation
Oklab main(Oklab Color)
{
// ...
}
2D Modifier (Zoom, Distortion, ...)
UV main(UV Input)
{
// ...
}
Image
Oklab main(UV uv)
{
// ...
}
Math function
float main(float x)
{
// ...
}
Parametric curve
UV main(float Percentage)
{
// ...
}
Mask / Greyscale image
float main(UV uv)
{
// ...
}
Blend Mode
Oklab_PremultipliedA main(Oklab_PremultipliedA Over, Oklab_PremultipliedA Under)
{
// ...
}
Conversion to Black & White
float main(Oklab Color)
{
// ...
}
Colorizer
Oklab main(float Greyscale)
{
// ...
}
2D SDF
SignedDistance main(UV uv)
{
// ...
}
3D SDF
SignedDistance main(vec3 pos)
{
// ...
}