MetaSL provides a set of standard library functions that can be called in shader methods and in user-defined (global) functions. Most functions may be used with more than one data type for their return type and arguments; in this case, the function is said to be overloaded.
For example, the abs function returns the absolute value of its parameter. If it is called with an argument of type int, it returns a value of type int:
int abs(int x)
Call with an argument of type float, however, abs returns a float:
float abs(float x)
For aggregate types like float3, function abs will return an aggreate type of the same simple type, using the appropriate version of abs on each component:
float3 abs(float3 x)
To simplify the documentation of a given function, the various sets of data types are represented by the symbols in the following table. A symbol in a declaration represents the same actual type throughout the function.
For example, function max is described in this way:
The type chosen for N — a non-matrix numeric type — must be the same throughout the function call. For example, if the type of argument a is float3, then the type of argument b must also be of float3, and the function will return a value of float3.
float3 max(float3 a, float3 b)
However, five functions — clamp, fmod, lerp, pow, and smoothstep — can be used with mixed argument types. Each possible combination is therefore listed individually.
| Symbol | Types represented by the symbol | MetaSL type names |
| B | All Boolean types | bool bool2 bool3 bool4 |
| I | All integer types | int int2 int3 int4 |
| V | Vector floating-point types | float2 float3 float4 Color3 Color |
| F | Vector and scalar floating-point types | float float2 float3 float4 Color3 Color |
| C | Color types | Color3 Color Spectrum |
| S | F + Spectrum All non-matrix floating-point types |
float float2 float3 float4 Color3 Color Spectrum |
| N | I + S All non-matrix numeric types |
int int2 int3 int4 float float2 float3 float4 Color3 Color Spectrum |
| A | B + I + S All Boolean types and all non-matrix numeric types |
bool bool2 bool3 bool4 int int2 int3 int4 float float2 float3 float4 Color3 Color Spectrum |
| M | Matrices of dimensions {2,3,4}x{2,3,4} containing elements of type half, float, or double. | half2x2 half2x3 half2x4 half3x2 half3x3 half3x4 half4x2 half4x3 half4x4 float2x2 float2x3 float2x4 float3x2 float3x3 float3x4 float4x2 float4x3 float4x4 double2x2 double2x3 double2x4 double3x2 double3x3 double3x4 double4x2 double4x3 double4x4 |
| Color tex1D(texture1D tex, float coord) | Sample a one dimensional texture and return a color value. |
| Color tex2D(texture2D tex, float2 coord) | Sample a two dimensional texture and return a color value. |
| Color tex3D(texture3D tex, float3 coord) | Sample a two dimensional texture and return a color value. |
| Color texCUBE(textureCUBE tex, float3 coord) | Sample a cube texture and return a color value. |