Skip to content

Matrix Uniforms

These uniforms store matrices used for converting between coordinate spaces. More info on the coordinate spaces used in Iris can be found in the Coordinate Spaces page.

gbufferModelView

uniform mat4 gbufferModelView;

Transforms coordinates from player space to view/eye space.

vec3 view_pos = gbufferModelView * vec4(feet_player_pos, 1.0);
vec3 view_pos = mat3(gbufferModelView) * eye_player_pos;

gbufferModelViewInverse

uniform mat4 gbufferModelViewInverse;

Equal to inverse(gbufferModelView), but calculated on the CPU to avoid running the expensive inverse() function on the GPU.


gbufferProjection

uniform mat4 gbufferProjection;

Equal to the projectionMatrix used by all gbuffers programs except for gbuffers_hand and gbuffers_hand_water, where the projectionMatrix multiplies the Z axis by MC_HAND_DEPTH to move the hand closer to the camera than the rest of the world.


gbufferProjectionInverse

uniform mat4 gbufferProjectionInverse;

Equal to inverse(gbufferProjection), but calculated on the CPU to avoid running the expensive inverse() function on the GPU.


shadowModelView

uniform mat4 shadowModelView;

Equal to the modelViewMatrix when the shadow map was generated in the shadow program.


shadowModelViewInverse

uniform mat4 shadowModelViewInverse;

Equal to inverse(shadowModelView), but calculated on the CPU to avoid running the expensive inverse() function on the GPU.


shadowProjection

uniform mat4 shadowProjection;

Equal to the projectionMatrix when the shadow map was generated in the shadow program.


shadowProjectionInverse

uniform mat4 shadowProjectionInverse;

Equal to inverse(shadowProjection), but calculated on the CPU to avoid running the expensive inverse() function on the GPU.


gbufferPreviousModelView

uniform mat4 gbufferPreviousModelView;

The value of gbufferModelView in the previous frame.


gbufferPreviousProjection

uniform mat4 gbufferPreviousProjection;

The value of gbufferProjection in the previous frame.


gl_ModelViewMatrix

gl_ModelViewMatrix

Transforms coordinates from model/local space to view/eye space.

Equal to mat4(1.0) in begin, prepare, deferred, composite and final programs.

vec3 model_pos = gl_Vertex.xyz;
vec4 view_pos = gl_ModelViewMatrix * vec4(model_pos, 1.0);
vec4 clip_pos = gl_ProjectionMatrix * view_pos;
gl_Position = clip_pos;

Equivalent to modelViewMatrix in the core profile.

uniform mat4 modelViewMatrix;
[...]
vec3 model_pos = vaPosition + chunkOffset;
vec4 view_pos = modelViewMatrix * vec4(model_pos, 1.0);
vec4 clip_pos = projectionMatrix * view_pos;
gl_Position = clip_pos;

modelViewMatrixInverse

uniform mat4 modelViewMatrixInverse;

Equal to inverse(modelViewMatrix), but calculated on the CPU to avoid running the expensive inverse() function on the GPU.


gl_ProjectionMatrix

gl_ProjectionMatrix

Transforms coordinates from view/eye space to clip space.

vec3 model_pos = gl_Vertex.xyz;
vec4 view_pos = gl_ModelViewMatrix * vec4(model_pos, 1.0);
vec4 clip_pos = gl_ProjectionMatrix * view_pos;
gl_Position = clip_pos;

Equivalent to projectionMatrix in the core profile.

uniform mat4 projectionMatrix;
[...]
vec3 model_pos = vaPosition + chunkOffset;
vec4 view_pos = modelViewMatrix * vec4(model_pos, 1.0);
vec4 clip_pos = projectionMatrix * view_pos;
gl_Position = clip_pos;

projectionMatrixInverse

uniform mat4 projectionMatrixInverse;

Equal to inverse(projectionMatrix), but calculated on the CPU to avoid running the expensive inverse() function on the GPU.


gl_NormalMatrix

gl_NormalMatrix
vec3 normal = gl_NormalMatrix * gl_Normal;

Matrix to transform a model space normal vector to view space. Equivalent to normalMatrix in the core profile.

uniform mat4 normalMatrix;
[...]
vec3 normal = normalMatrix * vaNormal;

gl_TextureMatrix[0]

gl_TextureMatrix[0]

Transforms texture coordinates. Mainly used in gbuffers_armor_glint to scroll the texture over time, but may be applied to other geometry as well (especially by mods). It is therefore strongly recommended to use this matrix in all gbuffers-style programs utilizing gl_MultiTexCoord0.

vec2 coord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;

Equivalent to textureMatrix in the core profile.

vec2 coord = (textureMatrix * vec4(vaUV0, 0.0, 1.0)).xy;

gl_TextureMatrix[1]

gl_TextureMatrix[1]

Transforms lightmap texture coordinates. It is therefore strongly recommended to use this matrix in all gbuffers-style programs utilizing gl_MultiTexCoord1.

vec2 lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;

An equivalent matrix for the core profile can be formulated as follows.

const mat4 TEXTURE_MATRIX_2 = mat4(vec4(0.00390625, 0.0, 0.0, 0.0), vec4(0.0, 0.00390625, 0.0, 0.0), vec4(0.0, 0.0, 0.00390625, 0.0), vec4(0.03125, 0.03125, 0.03125, 1.0));
vec2 lmcoord = (TEXTURE_MATRIX_2 * vec4(vaUV2, 0.0, 1.0)).xy;