Shaders are written in Metal

Shader Guide

Shader

Default Shader

fragment float4 shader() {
	return float4(u, v, 0.0, 1.0);
}

Shader 1.png

This returns a gradient Graphic, based on predefined u (x) and v (y) variables.

<aside> <img src="/icons/light-bulb_gray.svg" alt="/icons/light-bulb_gray.svg" width="40px" />

The return value of type float4 is representing RGBA of the pixel at u and v.

</aside>

Predefined Variables

<aside> <img src="/icons/light-bulb_gray.svg" alt="/icons/light-bulb_gray.svg" width="40px" />

To access the float2 components append .x or .y, and for a color’s float4 components .r, .g, .b, .a.

</aside>

User Defined Variables

In the Shader node, custom variable and textures can be added via inlets.

In properties, use External Inlets to add the variables, along with names.

Once a variable is created, a new inlet will be added to the node.

Sampling Pixel Colors