WebGL GLSL Reference
Based on OpenGL ES Shading Language 1.0
By Sohail Ajmal
abs
Summary
return the absolute value of the parameter
Syntax
genType abs(genType)
Example
float x = abs( 0.5 - 1.0);
// x = [ 0.5 - 1.0 ] = 0.5
See Also
Links
acos
Summary
return the arccosine of the parameter
Syntax
genType acos(genType)
Example
See Also
Links
all
Summary
check whether all elements of a boolean vector are true
Syntax
bool all(bvec)
Example
See Also
Links
any
Summary
check whether any element of a boolean vector is true
Syntax
bool any(bvec)
Example
See Also
Links
asin
Summary
return the arcsine of the parameter
Syntax
genType asin(genType)
Example
See Also
Links
atan
Summary
return the arc-tangent of the parameters
Syntax
genType atan(genType, genType)
genType atan(genType)
Example
See Also
Links
ceil
Summary
find the nearest integer that is greater than or equal to the parameter
Syntax
genType ceil(genType)
Example
See Also
Links
clamp
Summary
constrain a value to lie between two further values
Syntax
genType clamp(genType, genType, genType)
genType clamp(genType, float, float)
Example
See Also
Links
cos
Summary
return the cosine of the parameter
Syntax
genType cos(genType)
Example
See Also
Links
cross
Summary
calculate the cross product of two vectors
Syntax
vec3 cross(vec3, vec3)
Example
See Also
Links
degrees
Summary
convert a quantity in radians to degrees
Syntax
genType degrees(genType)
Example
See Also
Links
distance
Summary
calculate the distance between two points
Syntax
float distance(genType, genType)
Example
See Also
Links
dot
Summary
calculate the dot product of two vectors
Syntax
float dot(genType, genType)
Example
See Also
Links
equal
Summary
perform a component-wise equal-to comparison of two vectors
Syntax
bvec equal(vec, vec)
Example
See Also
lessThan lessThanEqual greaterThan greaterThanEqual notEqual any all not
Links
exp
Summary
return the natural exponentiation of the parameter
Syntax
genType exp(genType)
Example
See Also
Links
exp2
Summary
return 2 raised to the power of the parameter
Syntax
genType exp2(genType)
Example
See Also
Links
faceforward
Summary
return a vector pointing in the same direction as another
Syntax
genType faceforward(genType, genType, genType)
Example
See Also
Links
floor
Summary
find the nearest integer less than or equal to the parameter
Syntax
genType floor(genType)
Example
See Also
Links
fract
Summary
compute the fractional part of the argument
Syntax
genType fract(genType)
Example
See Also
Links
greaterThan
Summary
perform a component-wise greater-than comparison of two vectors
Syntax
bvec greaterThan(vec, vec)
Example
See Also
lessThan lessThanEqual greaterThanEqual equal notEqual any all not
Links
greaterThanEqual
Summary
perform a component-wise greater-than-or-equal comparison of two vectors
Syntax
bvec greaterThanEqual(vec, vec)
Example
See Also
lessThan lessThanEqual greaterThan equal notEqual any all not
Links
inversesqrt
Summary
return the inverse of the square root of the parameter
Syntax
genType inversesqrt(genType)
Example
See Also
Links
length
Summary
calculate the length of a vector
Syntax
float length(genType)
Example
See Also
Links
lessThan
Summary
perform a component-wise less-than comparison of two vectors
Syntax
bvec lessThan(vec, vec)
Example
See Also
lessThanEqual greaterThan greaterThanEqual equal notEqual any all not
Links
lessThanEqual
Summary
perform a component-wise less-than-or-equal comparison of two vectors
Syntax
bvec lessThanEqual(vec, vec)
Example
See Also
lessThan greaterThan greaterThanEqual equal notEqual any all not
Links
log
Summary
return the natural logarithm of the parameter
Syntax
genType log(genType)
Example
See Also
Links
log2
Summary
return the base 2 logarithm of the parameter
Syntax
genType log2(genType)
Example
See Also
Links
matrixCompMult
Summary
perform a component-wise multiplication of two matrices
Syntax
mat matrixCompMult(mat, mat)
Example
See Also
Links
max
Summary
return the greater of two values
Syntax
genType max(genType, genType)
genType max(genType, float)
Example
See Also
Links
min
Summary
return the lesser of two values
Syntax
genType min(genType, genType)
genType min(genType, float)
Example
See Also
Links
mix
Summary
linearly interpolate between two values
Syntax
genType mix(genType, genType, genType)
genType mix(genType, genType, float)
Example
See Also
Links
mod
Summary
compute value of one parameter modulo another
Syntax
genType mod(genType, float)
genType mod(genType, genType)
Example
See Also
Links
normalize
Summary
calculate the normalize product of two vectors
Syntax
genType normalize(genType)
Example
See Also
Links
not
Summary
logically invert a boolean vector
Syntax
bvec not(bvec)
Example
See Also
Links
notEqual
Summary
perform a component-wise not-equal-to comparison of two vectors
Syntax
bvec notEqual(vec, vec)
Example
See Also
lessThan lessThanEqual greaterThan greaterThanEqual equal any all not
Links
pow
Summary
return the value of the first parameter raised to the power of the second
Syntax
genType pow(genType, genType)
Example
See Also
Links
radians
Summary
convert a quantity in degrees to radians
Syntax
genType radians(genType)
Example
See Also
Links
reflect
Summary
calculate the reflection direction for an incident vector
Syntax
genType reflect(genType, genType)
Example
See Also
Links
refract
Summary
calculate the refraction direction for an incident vector
Syntax
genType refract(genType, genType, float)
Example
See Also
Links
sign
Summary
extract the sign of the parameter
Syntax
genType sign(genType)
Example
See Also
Links
sin
Summary
return the sine of the parameter
Syntax
genType sin(genType)
Example
See Also
Links
smoothstep
Summary
perform Hermite interpolation between two values
Syntax
genType smoothstep(genType, genType, genType)
genType smoothstep(float, float, genType)
Example
See Also
Links
sqrt
Summary
return the square root of the parameter
Syntax
genType sqrt(genType)
Example
See Also
Links
step
Summary
generate a step function by comparing two values
Syntax
genType step(genType, genType)
genType step(float, genType)
Example
See Also
Links
tan
Summary
return the tangent of the parameter
Syntax
genType tan(genType)
Example