Graphics Reference
In-Depth Information
Matrix Functions
GLSL has several useful functions for matrices, including componentwise
multiplication, the outer product, and the transpose. If no matrix type is other-
wise specified, mat is used for any matrix type.
Multiply matrix x by matrix y compo-
nent-wise, so that result[i][j] is the scalar
product of x[i][j] and y[i][j] . Note: to get
linear algebraic matrix multiplication,
use the multiply operator (*).
mat matrixCompMult(mat x, mat y)
Treats the first parameter c as a column
vector (matrix with one column) and
the second parameter r as a row vector
(matrix with one row) and does a linear
algebraic matrix multiply c * r , yielding
a matrix whose number of rows is the
number of components in c and whose
number of columns is the number of
components in r .
mat2 outerProduct(vec2 c, vec2 r)
mat3 outerProduct(vec3 c, vec3 r)
mat4 outerProduct(vec4 c, vec4 r)
mat2x3 outerProduct(vec3 c, vec2 r)
mat3x2 outerProduct(vec2 c, vec3 r)
mat2x4 outerProduct(vec4 c, vec2 r)
mat4x2 outerProduct(vec2 c, vec4 r)
mat3x4 outerProduct(vec4 c, vec3 r)
mat4x3 outerProduct(vec3 c, vec4 r)
Returns a matrix that is the transpose of
m ; m need not be square, as is shown.
The input matrix m is not modified.
mat2 transpose(mat2 m)
mat3 transpose(mat3 m)
mat4 transpose(mat4 m)
mat2x3 transpose(mat3x2 m)
mat3x2 transpose(mat2x3 m)
mat2x4 transpose(mat4x2 m)
mat4x2 transpose(mat2x4 m)
mat3x4 transpose(mat4x3 m)
mat4x3 transpose(mat3x4 m)
Relational Functions for Vectors
GLSL extends the familiar relational operators for scalars to a set of relational
functions for vectors. These compare vectors componentwise and return a
bvec result that can be used for parallel comparisons. There are also several
functions that can convert a bvec result to a single Boolean scalar. In these
descriptions, vec is a real vector, ivec is an integer vector, and bvec is a Boolean
vector, and their lengths are arbitrary except that in each case the lengths are
equal.
Search WWH ::




Custom Search