GLSL built-in function

determinant()

Returns a square matrix determinant, measuring signed scale.

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

Syntax

float determinant(mat m)

Parameters

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

Return value

One float containing the determinant of the square matrix m; zero indicates a singular matrix.

Live example

Edit the code and the preview updates as you type.

What determinant does

Returns a square matrix determinant, measuring signed scale.

Read the preview

For mat2(x,0.0,0.0,y), the determinant is x*y, so opposite quadrants share colors. Replace y with 1.0 to make the result depend only on horizontal position.

Core call

determinant(mat2(x,0.0,0.0,y));

Zero means singular; a negative result indicates orientation reversal.

Experiment

Change mat2(x,0.0,0.0,y) to mat2(x,1.0,1.0,y). The determinant becomes x*y - 1, shifting the color range toward its lower end.

Specification

GLSL ES 3.00 built-in functions, chapter 8

Related functions