Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ float shadow = step(shadowScreenPos.z, texture(shadowtex0, shadowScreenPos.xy).r

with

```
```glsl
vec3 shadow = getShadow(shadowScreenPos);
```

Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/current/How To/coordinate_spaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ It is also worth noting that in third person mode, view bobbing is disabled, and
## Shadow Space
"Shadow Space" can refer to a number of different coordinate spaces, all of which are used for the [shadow pass](/current/reference/programs/shadow/). As such, the "shadow" versions of coordinate spaces are generally equivalent to their normal versions but from the perspective of the shadow camera (the sun/moon). The shadow spaces include **shadow view space**, **shadow clip space**, **shadow NDC space**, and **shadow screen space**.

In the [shadow pass](/current/reference/programs/shadow/), the same base matrices are used ([`modelViewMatrix`](/current/reference/uniforms/matrices/#modelviewmatrix), [`projectionMatrix`](/current/reference/uniforms/matrices/#projectionmatrix), etc), or the `shadow` matrix uniforms (e.g. [`shadowModelView`](/current/reference/uniforms/matrices/#shadowmodelview), [`shadowProjection`](/current/reference/uniforms/matrices/#shadowprojection)) can be used from any program. When sampling the shadow map, positions can be transformed into **player space**, and from there back into *shadow screen space*.
In the [shadow pass](/current/reference/programs/shadow/), the same base matrices are used ([`gl_ModelViewMatrix`](/current/reference/uniforms/matrices/#gl_modelviewmatrix), [`gl_ProjectionMatrix`](/current/reference/uniforms/matrices/#gl_projectionmatrix), etc), or the `shadow` matrix uniforms (e.g. [`shadowModelView`](/current/reference/uniforms/matrices/#shadowmodelview), [`shadowProjection`](/current/reference/uniforms/matrices/#shadowprojection)) can be used from any program. When sampling the shadow map, positions can be transformed into **player space**, and from there back into *shadow screen space*.
27 changes: 27 additions & 0 deletions src/content/docs/current/Reference/Attributes/ftransform.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: ftransform
description: The vertex position in clip space.
sidebar:
label: ftransform
order: 2
---

### `ftransform`

**Valid Programs**: `*.vsh`

---

Function returning the vertex position in clip space.

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

vec4 clip_pos = ftransform(); // Equivalent to the above, not accounting for possible rounding differences.

gl_Position = clip_pos;
```
4 changes: 3 additions & 1 deletion src/content/docs/current/Reference/Attributes/gl_Color.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ The vertex color attribute.

The color attribute is often used to apply tints to colored blocks such as leaves, grass, water, etc. It also contains the [vanilla ambient occlusion](/current/reference/constants/ambientocclusionlevel/) and, if enabled, the [old lighting](/current/reference/shadersproperties/features/#oldlighting).

Enabling [`separateAo`](/current/reference/shadersproperties/features/#separateao) will move the ambient occlusion from the `rgb` components of `gl_Color` to the `a` component, which can be applied later like this:
Enabling [`separateAo`](/current/reference/shadersproperties/features/#separateao) will move the ambient occlusion from the `rgb` components of `gl_Color` to the `a` component in terrain programs, which can be applied later like this:

```glsl
vec3 color = gl_Color.rgb * gl_Color.a;
```

The `a` component includes tint for alpha in some non-terrain programs.

### `in vec4 vaColor;`

:::danger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ The fade-in progress of the geometry. This value is a `float` automatically decl

In `gbuffers_terrain.vsh`, the value will be a float in the range 0-1. In all other gbuffers programs, it will be declared as `const float mc_chunkFade = -1.0;`.

The variable will not be declared if the `FADE_VARIABLE` [feature flag](/current/reference/shadersproperties/flags/) is not available. You should check if the feature is available when using the variable.
The variable will not be declared if the `FADE_VARIABLE` [feature flag](/current/reference/shadersproperties/flags/) is not available. You should check if the feature is available when using the variable.
6 changes: 3 additions & 3 deletions src/content/docs/current/Reference/Buffers/ssbo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ SSBOs require OpenGL 4.3 support, which macOS does not have. For more informatio
### Fixed Size SSBOs
To define the SSBO with a fixed size, put the following in [`shaders.properties`](/current/reference/shadersproperties/overview/) and replace `<totalByteSize>` with the total size of the SSBO in bytes and replace `<index>` with a unique value from 0 to 8.

```
```properties
bufferObject.<index> = <byteSize>
```

### Screen-Sized SSBOs
SSBOs can also be defined as screen-sized (Iris 1.6.6 and later), where their size is relative to the screen dimensions. This is useful for storing data per-pixel. To use this, put the following in [`shaders.properties`](/current/reference/shadersproperties/overview/).

```
```properties
bufferObject.<index> = <byteSize> <isRelative> <scaleX> <scaleY>
```

Expand Down Expand Up @@ -75,4 +75,4 @@ void main() {

## Initialization Data File (Iris 1.8+)
### `bufferObject.<index> = <byteSize> <filePath>`
Iris 1.8 adds support for initializing an SSBO with data from a binary file. Simply append the file path to the end of the SSBO declaration in [`shaders.properties`](/current/reference/shadersproperties/overview/). The value is be initialized at on shader load/reload. This works with only fixed sized SSBOs, and if the size of the file is bigger than the SSBO Iris will throw an error. If the file is smaller than the SSBO, the remaining data in the SSBO will be uninitialized (and is likely to be garbage data).
Iris 1.8 adds support for initializing an SSBO with data from a binary file. Simply append the file path to the end of the SSBO declaration in [`shaders.properties`](/current/reference/shadersproperties/overview/). The value is be initialized at on shader load/reload. This works with only fixed sized SSBOs, and if the size of the file is bigger than the SSBO Iris will throw an error. If the file is smaller than the SSBO, the remaining data in the SSBO will be uninitialized (and is likely to be garbage data).
14 changes: 14 additions & 0 deletions src/content/docs/current/Reference/Macros/MAX_COLOR_BUFFERS.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: MAX_COLOR_BUFFERS
description: Maximum colortex texture count.
sidebar:
label: MAX_COLOR_BUFFERS
order: 2
badge:
text: Iris Only (1.10.5+)
variant: tip
---

### `MAX_COLOR_BUFFERS`

The maximum number of [colortex](/current/reference/buffers/colortex/) textures that a shader pack can use.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ sidebar:

### `MC_GLSL_VERSION`

The maximum GLSL version supported by the system. For example: 120, 330, 460, etc.
The maximum GLSL version supported by the system. For example: 120, 330, 460, etc.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ The maximum OpenGL version supported by the system, encoded in an integer format
For example:
- OpenGL 2.1 -> 210
- OpenGL 3.3 -> 330
- OpenGL 4.6 -> 460
- OpenGL 4.6 -> 460
4 changes: 2 additions & 2 deletions src/content/docs/current/Reference/Macros/MC_HAND_DEPTH.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ sidebar:

The clip space depth multiplier applied to geometry in [`gbuffers_hand`](/current/reference/programs/gbuffers/) and [`gbuffers_hand_water`](/current/reference/programs/gbuffers/).

The multiplier is applied in clip space automatically through the [projection matrix](/current/reference/uniforms/matrices/#projectionMatrix). When working backwards from the depth buffer, the multiplier should be applied in NDC space rather than screen space to produce the correct result, for example:
The multiplier is applied in clip space automatically through the [projection matrix](/current/reference/uniforms/matrices/#gl_projectionMatrix). When working backwards from the depth buffer, the multiplier should be applied in NDC space rather than screen space to produce the correct result, for example:

```glsl
float screenDepth = textureLod(depthtex0, texcoord, 0.0).r;
float ndcDepth = (screenDepth * 2.0 - 1.0) / MC_HAND_DEPTH;
```
```
14 changes: 14 additions & 0 deletions src/content/docs/current/Reference/Macros/MC_MIPMAP_LEVEL.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: MC_MIPMAP_LEVEL
description: The current maximum mipmap level.
sidebar:
label: MC_MIPMAP_LEVEL
order: 2
badge:
text: Iris Only (1.8.1+)
variant: tip
---

### `MC_MIPMAP_LEVEL`

The current maximum mipmap level.
20 changes: 19 additions & 1 deletion src/content/docs/current/Reference/Uniforms/camera.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ This value stores the world aligned direction the player model's head is facing.
----------------


## vehicleLookVector <Badge text="Iris Exclusive (1.10.4+)" variant="tip" size="medium" />
```glsl
uniform vec3 vehicleLookVector;
```
This value stores the world aligned direction that the currently used vehicle's model's head is facing.

----------------


## relativeVehiclePosition <Badge text="Iris Exclusive (1.10.4+)" variant="tip" size="medium" />
```glsl
uniform vec3 relativeVehiclePosition;
```
This value stores the world space offset from the position of the currently used vehicle to the camera's position.

----------------


## upPosition
```glsl
uniform vec3 upPosition;
Expand Down Expand Up @@ -153,4 +171,4 @@ This uniform stores the value in the depth buffer `depthtex0` at the center of t
```glsl
uniform bool firstPersonCamera;
```
This value is `true` when the player is in the first person camera view and `false` in any third person camera view.
This value is `true` when the player is in the first person camera view and `false` in any third person camera view.
12 changes: 9 additions & 3 deletions src/content/docs/current/Reference/Uniforms/id.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ This uniform stores the ID (from [`block.properties`](/current/reference/miscell
----------------


## vehicleId <Badge text="Iris Exclusive (1.10.4+)" variant="tip" size="medium" />
```glsl
uniform int vehicleId;
```
This uniform stores the ID (from [`entity.properties`](/current/reference/miscellaneous/entity_properties/)) of the vehicle currently used by the player. Value is `0` if no [`entity.properties`](/current/reference/miscellaneous/entity_properties/) is present. Value `65535` if [`entity.properties`](/current/reference/miscellaneous/entity_properties/) is present and the entity is not in the file.

----------------


## currentRenderedItemId <Badge text="Iris Exclusive" variant="tip" size="medium" />
```glsl
uniform int currentRenderedItemId;
Expand Down Expand Up @@ -96,7 +105,4 @@ uniform int heldBlockLightValue2;
```
The light strength of the item held in the player's offhand. This ranges from `0`-`15` for vanilla blocks, however some modded blocks may have a higher value.


----------------


46 changes: 30 additions & 16 deletions src/content/docs/current/Reference/Uniforms/matrices.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Equal to [`inverse(gbufferModelView)`](/current/reference/uniforms/matrices/#gbu
```glsl
uniform mat4 gbufferProjection;
```
Equal to the [`projectionMatrix`](/current/reference/uniforms/matrices/#projectionmatrix) used by all [gbuffers programs](/current/reference/programs/gbuffers/) except for `gbuffers_hand` and `gbuffers_hand_water`, where the [`projectionMatrix`](/current/reference/uniforms/matrices/#projectionmatrix) multiplies the Z axis by `MC_HAND_DEPTH` to move the hand closer to the camera than the rest of the world.
Equal to the [`gl_ProjectionMatrix`](/current/reference/uniforms/matrices/#gl_projectionmatrix) used by all [gbuffers programs](/current/reference/programs/gbuffers/) except for `gbuffers_hand` and `gbuffers_hand_water`, where the [`gl_ProjectionMatrix`](/current/reference/uniforms/matrices/#gl_projectionmatrix) multiplies the Z axis by `MC_HAND_DEPTH` to move the hand closer to the camera than the rest of the world.

----------------

Expand All @@ -53,7 +53,7 @@ Equal to [`inverse(gbufferProjection)`](/current/reference/uniforms/matrices/#gb
```glsl
uniform mat4 shadowModelView;
```
Equal to the [`modelViewMatrix`](/current/reference/uniforms/matrices/#modelviewmatrix) when the shadow map was generated in the [shadow program](/current/reference/programs/shadow/).
Equal to the [`gl_ModelViewMatrix`](/current/reference/uniforms/matrices/#gl_modelviewmatrix) when the shadow map was generated in the [shadow program](/current/reference/programs/shadow/).

----------------

Expand All @@ -71,7 +71,7 @@ Equal to [`inverse(shadowModelView)`](/current/reference/uniforms/matrices#shado
```glsl
uniform mat4 shadowProjection;
```
Equal to the [`projectionMatrix`](/current/reference/uniforms/matrices/#projectionmatrix) when the shadow map was generated in the [shadow program](/current/reference/programs/shadow).
Equal to the [`gl_ProjectionMatrix`](/current/reference/uniforms/matrices/#gl_projectionmatrix) when the shadow map was generated in the [shadow program](/current/reference/programs/shadow).

----------------

Expand Down Expand Up @@ -137,17 +137,17 @@ gl_Position = clip_pos;

----------------

## gl_ModelViewMatrixInverse
```glsl
gl_ModelViewMatrixInverse
```
Equal to [`inverse(gl_ModelViewMatrix)`](/current/reference/uniforms/matrices/#gl_modelviewmatrix), but calculated on the CPU to avoid running the expensive `inverse()` function on the GPU.

## modelViewMatrixInverse

:::danger
This uniform only works with the `core` profile in Minecraft 1.17 and newer. It is recommended to use the `compatibility` profile with Iris for better support. See [this page](/current/how-to/compatibility_vs_core) for more information.
:::
Equivalent to `modelViewMatrixInverse` in the [`core` profile](/current/how-to/compatibility_vs_core).

```glsl
uniform mat4 modelViewMatrixInverse;
```
Equal to [`inverse(modelViewMatrix)`](/current/reference/uniforms/matrices/#modelviewmatrix), but calculated on the CPU to avoid running the expensive `inverse()` function on the GPU.

----------------

Expand Down Expand Up @@ -180,24 +180,38 @@ vec4 clip_pos = projectionMatrix * view_pos;
gl_Position = clip_pos;
```



----------------

## gl_ProjectionMatrixInverse
```glsl
gl_ProjectionMatrixInverse
```
Equal to [`inverse(gl_ProjectionMatrix)`](/current/reference/uniforms/matrices/#gl_projectionmatrix), but calculated on the CPU to avoid running the expensive `inverse()` function on the GPU.

## projectionMatrixInverse
:::danger
This uniform only works with the `core` profile in Minecraft 1.17 and newer. It is recommended to use the `compatibility` profile with Iris for better support. See [this page](/current/how-to/compatibility_vs_core) for more information.
:::
Equivalent to `projectionMatrixInverse` in the [`core` profile](/current/how-to/compatibility_vs_core).

```glsl
uniform mat4 projectionMatrixInverse;
```
Equal to [`inverse(projectionMatrix)`](/current/reference/uniforms/matrices/#projectionmatrix), but calculated on the CPU to avoid running the expensive `inverse()` function on the GPU.

----------------


## gl_ModelViewProjectionMatrix
```glsl
gl_ModelViewProjectionMatrix
```
Equal to `gl_ProjectionMatrix * gl_ModelViewMatrix`, not accounting for possible rounding differences.

```glsl
vec3 model_pos = gl_Vertex.xyz;
vec4 clip_pos = gl_ModelViewProjectionMatrix * vec4(model_pos, 1.0);

gl_Position = clip_pos;
```

----------------

## gl_NormalMatrix
```glsl
gl_NormalMatrix
Expand Down
Loading