# Built-in Common Functions

## introduction

The functions for trigonometry in GLSL are the similar to those in Java. .

## functions

Listed below are all the trigonometric functions. Many of the data types are listed as genType. This indicates that the data type can be float, vec2, vec3 or vec4. Each component of the vectors are operated on by the function.

function signaturedescription
genType abs(genType α)returns the absolute value of α.i.e, -α if α < 0;
genType sign(genType α)returns
• -1 for α < 0
• 0 for α = 0
• 1 for α > 0
genType floor(genType α)returns the nearest integer less than or equal to α
genType ceil(genType α)returns the nearest integer greater than or equal to α
genType mod(genType α, float β)

genType mod(genType α, genType β)
equivalent to α%β in Java
genType min(genType α, float β)

genType min(genType α, genType β)
returns
• α when α < β
• &beta when β < α
genType max(genType α, float β)

genType max(genType α, genType β)
returns
• α when α > β
• &beta when β > α
genType clamp(genType α, float β, float δ)

genType clamp(genType α, genType β, genType δ)
returns
• α when β < α < δ
• β when α > β
• δ when α > δ
genType mix(genType α, float β, float δ)

genType mix(genType α, genType β, genType δ)
returns the linear blend of α and β. i.e. α + δ(β - α)
genType step(float limit, genType α)

genType step(genType limit, genType α)
returns
• 0 when α < limit;
• 1 when α > limit;
genType smoothstep(float α0, float α1, genType β)

genType smoothstep(genType α0, genType α1, genType β)
returns
• 0 when β < α0
• 1 when β > α1;
• smooth Hermite interpolation
when α0 < β < α1