mat2x2f
Function
mat2x2f builds a matrix with 2 columns and 2 rows. Each column describes the image of one input basis direction.
Compare examples
Compare the zero matrix with distinct columns and a diagonal pattern. Read the displayed matrix across rows and the constructor down columns.
Example 1mat2x2f()
0000 - Result
[[0,0],[0,0]]
Example 2mat2x2f(1., 2., 3., 4.)
1324 - Result
[[1,3],[2,4]]
Example 3mat2x2f(1., 0., 0., 1.)
1001 - Result
[[1,0],[0,1]]
The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.
When to use it
Use a matrix to represent a linear transformation. Reading it by columns makes the constructor order visible.
Inputs and limits
Components are supplied in column-major order. An argument-free constructor makes a zero matrix. Rectangular matrices do not have a determinant.
For shader input rules and precision, consult WGSL and GLSL ES 3.00.
Related functions
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Builds a mat2x2f, the same type as mat2x2 under WGSL's predeclared alias, in the same four ways: from 2 vec2 columns, from 4 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).
Syntax
declare function mat2x2f(): mat2x2declare function mat2x2f(c0: vec2, c1: vec2): mat2x2declare function mat2x2f(e0: number, e1: number, e2: number, e3: number): mat2x2declare function mat2x2f(m: mat2x2): mat2x2declare function mat2x2f(m: mat2x3): mat2x2declare function mat2x2f(m: mat2x4): mat2x2declare function mat2x2f(m: mat3x2): mat2x2declare function mat2x2f(m: mat3x3): mat2x2declare function mat2x2f(m: mat3x4): mat2x2declare function mat2x2f(m: mat4x2): mat2x2declare function mat2x2f(m: mat4x3): mat2x2declare function mat2x2f(m: mat4x4): mat2x2A number in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.
type f32 = number & { readonly [f32Tag]?: true }
A number you write as a type is inferred from its uses, and f32, i32 and u32 fix a width; the TypeScript constructs page carries that row with the compiler's emit.