## Description

The following table describes the list of built-in common functions. These all operate component-wise. The description is per-component. We use the generic type name gentype to indicate that the function can take float, float2, float3, float4, float8, float16, double, double2, double3, double4, double8 or double16 as the type for the arguments. We use the generic type name gentypef to indicate that the function can take float, float2, float3, float4, float8, or float16 as the type for the arguments. We use the generic type name gentyped to indicate that the function can take double, double2, double3, double4, double8 or double16 as the type for the arguments.

The built-in common functions are implemented using the round to nearest even rounding mode.

 Function Description gentype clamp(gentype x, gentype minval, gentype maxval) gentypef clamp(gentypef x, float minval, float maxval) gentyped clamp(gentyped x, double minval, double maxval) Returns fmin(fmax(x, minval), maxval). Results are undefined if minval > maxval. gentype degrees(gentype radians) Converts radians to degrees, i.e. (180 / π) * radians. gentype max(gentype x, gentype y) gentypef max(gentypef x, float y) gentyped max(gentyped x, double y) Returns y if x < y, otherwise it returns x. If x or y are infinite or NaN, the return values are undefined. gentype min(gentype x, gentype y) gentypef min(gentypef x, float y) gentyped min(gentyped x, double y) Returns y if y < x, otherwise it returns x. If x or y are infinite or NaN, the return values are undefined. gentype mix(gentype x, gentype y, gentype a) gentypef mix(gentypef x, gentypef y, float a) gentyped mix(gentyped x, gentyped y, double a) Returns the linear blend of x & y implemented as: x + (y - x) * a a must be a value in the range [0.0, 1.0]. If a is not in the range [0.0, 1.0], the return values are undefined. gentype radians(gentype degrees) Converts degrees to radians, i.e. (π / 180) * degrees. gentype step(gentype edge, gentype x) gentypef step(float edge, gentypef x) gentyped step(double edge, gentyped x) Returns 0.0 if x < edge, otherwise it returns 1.0. gentype smoothstep(gentype edge0, gentype edge1, gentype x) gentypef smoothstep(float edge0, float edge1, gentypef x) gentyped smoothstep(double edge0, double edge1, gentyped x) Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where you would want a threshold function with a smooth transition. This is equivalent to: gentype t; t = clamp ((x - edge0) / (edge1 - edge0), 0, 1); return t * t * (3 - 2 * t); Results are undefined if edge0 >= edge1 or if x, edge0 or edge1 is a NaN. gentype sign(gentype x) Returns 1.0 if x > 0, -0.0 if x = -0.0, +0.0 if x = +0.0, or -1.0 if x < 0. Returns 0.0 if x is a NaN.