Shaders a written in Metal
A shader is code run for every pixel in a graphic.

fragment float4 shader() {
float red = 1.0;
float green = 1.0;
float blue = 1.0;
float alpha = 1.0;
return float4(red, green, blue, alpha);
}
This shader returns 1.0 for every channel in the pixel, displaying a fully white graphic. Colors are represented but not limited to values between 0.0 and 1.0.
fragment float4 shader() {
return float4(u, v, 0.0, 1.0);
}

To determine the location of the current pixel, use the normalized uv coordinates. This variable is pre defined and available in the main shader function.
float smooth(float value) {
return cos(value * M_PI_F + M_PI_F) / 2.0 + 0.5;
}
fragment float4 shader() {
return float4(smooth(u), smooth(v), 0.0, 1.0);
}

Define a function by first defining what type to return, in this case a float. Then the name and the arguments. This function smoothes out values between 0.0 and 1.0.
<aside> <img src="/icons/light-bulb_gray.svg" alt="/icons/light-bulb_gray.svg" width="40px" />
Note that the custom function needs to be above the main shader function for the shader to compile.
</aside>
