GLSL built-in function

transpose()

Swaps matrix rows and columns.

Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment

Syntax

mat transpose(mat m)

Parameters

m
Input declared in the signature; match its type and dimensions

Return value

A matrix with rows and columns exchanged; result[column][row] equals m[row][column].

Live example

Edit the code and the preview updates as you type.

What transpose does

Swaps matrix rows and columns.

Read the preview

Transposing mat2(1.0,0.6,0.0,1.0) moves the shear coefficient to the other off-diagonal position. Set 0.6 to 0.0 to see the grid return to square alignment.

Core call

transpose(mat2(1.0,0.6,0.0,1.0))*vec2(x,y);

GLSL matrix constructors are column-major; transpose changes the shear direction.

Experiment

Replace transpose(mat2(1.0,0.6,0.0,1.0)) with the matrix itself. The grid shears along the other coordinate, exposing the row/column swap.

Specification

GLSL ES 3.00 built-in functions, chapter 8

Related functions