mat4
Constructs or converts a 4x4 matrix (mat4) from various inputs, used to perform complete 3D transformations—translation, rotation, and scale—on objects in 3D space. It is the core of the rendering pipeline.
Core Advantages
It is the only node that can encapsulate translation, rotation, and scale into a single operation. It allows the core matrices of the rendering pipeline (e.g., `modelMatrix`, `projectionMatrix`) to be intuitively connected and used in the node graph, thus visualizing the complex process of vertex space transformation.
Common Uses
Performing the fundamental vertex space transformation (Model -> View -> Clip Space)
Representing the transformation matrix of a single bone in skinned animation
Providing a unique transformation matrix for each instance in instanced rendering
Representing the light's view-projection matrix in shadow mapping techniques
How to adjust
Adjusting the inputs that form the matrix directly changes the geometric state of the 3D object. For example, dynamically altering its translation component will move the object in space; altering its rotation component will make it spin; and altering its scale component will cause the object to 'breathe' by growing larger or smaller.
Code Examples
1// The core vertex transformation pipeline
2// 1. Convert local vertex position to a homogeneous coordinate
3const position4 = vec4( positionLocal, 1.0 );
4
5// 2. Apply model-view and projection matrices in sequence
6const mvpPosition = projectionMatrix.mul( modelViewMatrix.mul( position4 ) );