What Built-in Matrix Types Exist in Modern GLSL?

Modern OpenGL Shading Language (GLSL) provides a comprehensive set of built-in matrix types designed for geometric transformations, lighting calculations, and projection mathematics. These types cover both square and non-square dimensions with support for single-precision and double-precision floating-point formats. In GLSL, matrix types are defined using column-major ordering, meaning data is accessed and structured as a collection of column vectors.

Matrix Naming Conventions

Matrix types in GLSL use the syntax matNxM or dmatNxM, where N specifies the number of columns and M specifies the number of rows. This notation is the inverse of standard mathematical matrix conventions (which typically specify rows first). When a matrix is square (\(N = M\)), shorthand aliases like matN and dmatN are standard.

Single-Precision Matrix Types (float)

Single-precision 32-bit floating-point matrices are the most commonly used types in standard graphics pipelines.

Double-Precision Matrix Types (double)

Introduced in GLSL 4.00 for precision-sensitive applications such as large-scale planetary rendering or scientific simulation, 64-bit double-precision types use the dmat prefix:

Core Features and Operations

GLSL treats matrices as first-class types with built-in hardware optimization: