2015-06-02 10:29:49 +00:00
|
|
|
## Mat4
|
|
|
|
4x4 floating point matrix
|
|
|
|
|
|
|
|
### Declaration
|
|
|
|
```glsl
|
|
|
|
mat4 aMat4 = mat4(1.0, 0.0, 0.0, 0.0, // 1. column
|
|
|
|
0.0, 1.0, 0.0, 0.0, // 2. column
|
|
|
|
0.0, 0.0, 1.0, 0.0, // 3. column
|
|
|
|
0.0, 0.0, 0.0, 1.0); // 4. column
|
|
|
|
mat4 bMat4 = mat4(1.0);
|
|
|
|
|
|
|
|
mat4 cMat4 = mat4(aVec4, bVec4, cVec4, dVec4);
|
|
|
|
mat4 dMat4 = mat4(aVec4, aVec3, bVec4, cVec4, aFloat);
|
|
|
|
```
|
|
|
|
|
|
|
|
### Description
|
2015-06-09 11:15:40 +00:00
|
|
|
```mat4``` data type is compose for a 4x4 matrix of floating point. As you can see above, can be initialize in different ways:
|
2015-06-02 10:29:49 +00:00
|
|
|
|
2015-06-09 11:15:40 +00:00
|
|
|
- Providing a value for each component column by column.
|
2015-06-02 10:29:49 +00:00
|
|
|
|
2015-06-09 11:15:40 +00:00
|
|
|
- Providing one value that is used for the components on the main diagonal.
|
2015-06-02 10:29:49 +00:00
|
|
|
|
2015-06-09 11:15:40 +00:00
|
|
|
- Providing a combination of vectors and scalars.
|
2015-06-02 10:29:49 +00:00
|
|
|
|
2015-06-09 11:15:40 +00:00
|
|
|
In the same way data can be accessed component-wise or column by column:
|
2015-06-02 10:29:49 +00:00
|
|
|
|
|
|
|
```glsl
|
|
|
|
aMat4[3][3] = 1.0;
|
|
|
|
float aFloat = aMat4[3][3];
|
|
|
|
|
|
|
|
aMat4[0] = vec4(1.0);
|
|
|
|
vec4 aVec4 = aMat4[0];
|
|
|
|
```
|
|
|
|
|
|
|
|
### See Also
|
|
|
|
[mat2](index.html#mat2.md), [mat3](index.html#mat3.md), [matrixCompMult()](index.html#matrixCompMult.md)
|