Skip to content

Commit

Permalink
Merge pull request #332 from IrisShaders/uniform_categories
Browse files Browse the repository at this point in the history
Uniform categories
  • Loading branch information
ninjamike1211 authored Oct 7, 2024
2 parents 991cb24 + d02c247 commit b254104
Show file tree
Hide file tree
Showing 147 changed files with 2,495 additions and 2,690 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
},
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/starlight": "^0.21.5",
"astro": "^4.3.5",
"@astrojs/starlight": "^0.28.2",
"astro": "^4.14.0",
"astro-og-canvas": "^0.5.0",
"canvaskit-wasm": "^0.39.1",
"sharp": "^0.32.5",
Expand Down
2,098 changes: 1,016 additions & 1,082 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/content/docs/reference/Attributes/mc_Entity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ When [`block.properties`](/reference/miscellaneous/block_properties) is not pres

The `y` component stores the "render type", which is `1` for fluids (water, lava, etc) and `-1` for all other blocks.

This attribute is only available for terrain. For other types of geometry, see [`entityid`](/reference/uniforms/general/entityid) and [`blockentityid`](/reference/uniforms/general/blockentityid).
This attribute is only available for terrain. For other types of geometry, see [`entityid`](/reference/uniforms/id#entityid) and [`blockentityid`](/reference/uniforms/id#blockentityid).
22 changes: 11 additions & 11 deletions src/content/docs/reference/Attributes/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Attributes are per-vertex data available ***only*** in the vertex stage. These v
### Compatibility attributes
The glsl compatibility profile provides several built in attributes. Iris/Optifine provide several attributes/uniforms to replace these when using the core profile. These "core profile" attributes are only available in MC 1.17+. The following shows these attributes:

| Compatibility | Core | Description |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | -------------------------- |
| `gl_Vertex` | [`vaPosition`](/reference/attributes/vaposition) + [`chunkOffset`](/reference/uniforms/general/chunkoffset) | vertex position |
| `gl_Color` | [`vaColor`](/reference/attributes/vacolor) | vertex color |
| `gl_Normal` | [`vaNormal`](/reference/attributes/vanormal) | vertex normal |
| `gl_NormalMatrix` | [`normalMatrix`](/reference/uniforms/matrices/normalmatrix) | normal matrix |
| `gl_MultiTexCoord0` | [`vaUV0`](/reference/attributes/vauv0) | texture uv coordinate |
| `gl_TextureMatrix[0]` | [`textureMatrix`](/reference/uniforms/matrices/texturematrix) | texture uv matrix |
| [`entityColor`](/reference/uniforms/general/entitycolor) | [`vaUV1`](/reference/attributes/vauv1) (not recommended even in core) | entity overlay |
| `gl_MultiTexCoord1` / `gl_MultiTexCoord2` | [`vaUV2`](/reference/attributes/vauv2) | lightmap coordinate |
| `gl_TextureMatrix[1]` | [`TEXTURE_MATRIX_2`](/reference/attributes/vauv2) (hardcoded matrix) | lightmap coordinate matrix |
| Compatibility | Core | Description |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `gl_Vertex` | [`vaPosition`](/reference/attributes/vaposition) + [`chunkOffset`](/reference/uniforms/rendering#chunkoffset) | vertex position |
| `gl_Color` | [`vaColor`](/reference/attributes/vacolor) | vertex color |
| `gl_Normal` | [`vaNormal`](/reference/attributes/vanormal) | vertex normal |
| `gl_NormalMatrix` | [`normalMatrix`](/reference/uniforms/matrices#normalmatrix) | normal matrix |
| `gl_MultiTexCoord0` | [`vaUV0`](/reference/attributes/vauv0) | texture uv coordinate |
| `gl_TextureMatrix[0]` | [`textureMatrix`](/reference/uniforms/matrices#texturematrix) | texture uv matrix |
| [`entityColor`](/reference/uniforms/rendering#entitycolor) | [`vaUV1`](/reference/attributes/vauv1) (not recommended even in core) | entity overlay |
| `gl_MultiTexCoord1` / `gl_MultiTexCoord2` | [`vaUV2`](/reference/attributes/vauv2) | lightmap coordinate |
| `gl_TextureMatrix[1]` | [`TEXTURE_MATRIX_2`](/reference/attributes/vauv2) (hardcoded matrix) | lightmap coordinate matrix |
2 changes: 1 addition & 1 deletion src/content/docs/reference/Attributes/vaNormal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Aside } from '@astrojs/starlight/components';

The vertex normal vector attribute, equivalent to `gl_Normal` from the compatibility profile.

The normal vector from `vaNormal` is in model space (which varies for different geometry). It can be converted to view space using [`normalMatrix`](/reference/uniforms/matrices/normalmatrix) (or `gl_NormalMatrix` in the compatibility profile).
The normal vector from `vaNormal` is in model space (which varies for different geometry). It can be converted to view space using [`normalMatrix`](/reference/uniforms/matrices#normalmatrix) (or `gl_NormalMatrix` in the compatibility profile).
```glsl
vec3 normal = normalMatrix * vaNormal;
```
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/reference/Attributes/vaPosition.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Aside } from '@astrojs/starlight/components';

---

The vertex position attribute. For terrain this is relative to the chunk and you must add [`chunkOffset`](/reference/uniforms/general/chunkoffset) as shown below:
The vertex position attribute. For terrain this is relative to the chunk and you must add [`chunkOffset`](/reference/uniforms/rendering#chunkoffset) as shown below:
```glsl
vec3 model_pos = vaPosition + chunkOffset;
vec4 view_pos = modelViewMatrix * vec4(model_pos, 1.0);
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/reference/Attributes/vaUV0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Aside } from '@astrojs/starlight/components';

The vertex texture coordinate attribute, equivalent to `gl_MultiTexCoord0` from the compatibility profile.

Usually the coordinate in `vaUV0` corresponds directly to the atlas texture coordinate, however some geometry (such as enchantment glint) requires a texture matrix. Therefore it is always recommended to use [`textureMatrix`](/reference/uniforms/matrices/texturematrix) (or `gl_TextureMatrix[0]` in the compatibility profile) in [gbuffers-style](/reference/programs/overview/#program-order) programs.
Usually the coordinate in `vaUV0` corresponds directly to the atlas texture coordinate, however some geometry (such as enchantment glint) requires a texture matrix. Therefore it is always recommended to use [`textureMatrix`](/reference/uniforms/matrices#texturematrix) (or `gl_TextureMatrix[0]` in the compatibility profile) in [gbuffers-style](/reference/programs/overview/#program-order) programs.
```glsl
vec2 coord = (textureMatrix * vec4(vaUV0, 0.0, 1.0)).xy;
```
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/reference/Attributes/vaUV1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ import { Aside } from '@astrojs/starlight/components';

---

The entity overlay attribute. It is recommended to use [`entityColor`](/reference/uniforms/general/entitycolor) instead.
The entity overlay attribute. It is recommended to use [`entityColor`](/reference/uniforms/rendering#entitycolor) instead.
2 changes: 1 addition & 1 deletion src/content/docs/reference/Buffers/colortex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ These buffers default to the display resolution, although this can be configured
All buffers default to `RGBA` format (which is `RGBA8` on most systems), but this can be configured as described in the [Texture Formats](/reference/buffers/texture_format) section.

#### Buffer clear
By default all buffers clear their values after each frame to solid black (all 0s including alpha), except `colortex0` which clears to the [`fogColor`](/reference/uniforms/general/fogcolor) with 1.0 alpha, and `colortex1` which clears to solid white (all 1s including alpha). This clearing behavior can be configured with the [`colortexNClear`](/reference/constants/buffer_clear) directive, and the clear color can be configured with the [`colortexNClearColor`](/reference/constants/buffer_clear_color) directive.
By default all buffers clear their values after each frame to solid black (all 0s including alpha), except `colortex0` which clears to the [`fogColor`](/reference/uniforms/rendering#fogcolor) with 1.0 alpha, and `colortex1` which clears to solid white (all 1s including alpha). This clearing behavior can be configured with the [`colortexNClear`](/reference/constants/buffer_clear) directive, and the clear color can be configured with the [`colortexNClearColor`](/reference/constants/buffer_clear_color) directive.

#### Ping-Pong buffers
Each colortex sampler actually contains two buffers, which allows you to read and write to the same buffer in a composite/deferred pass. The buffer flipping behavior can be controlled with the [`flip.<program>.<buffer>`](/reference/shadersproperties/buffer_flip) directive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ sidebar:

#### Location: any glsl file

Sets the half life in ticks for the transition time for the [`centerDepthSmooth`](/reference/uniforms/general/centerdepthsmooth) uniform. The default value is 1 tick.
Sets the half life in ticks for the transition time for the [`centerDepthSmooth`](/reference/uniforms/camera#centerdepthsmooth) uniform. The default value is 1 tick.
2 changes: 1 addition & 1 deletion src/content/docs/reference/Constants/drynessHalflife.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ sidebar:

#### Location: any glsl file

Sets the half life in ticks for the transition from dry to wet weather for the [`wetness`](/reference/uniforms/general/wetness) uniform. The default value is 200 ticks.
Sets the half life in ticks for the transition from dry to wet weather for the [`wetness`](/reference/uniforms/world#wetness) uniform. The default value is 200 ticks.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ sidebar:

#### Location: any glsl file

Sets the half life in ticks for the transition time for the [`eyeBrightnessSmooth`](/reference/uniforms/general/eyebrightnesssmooth) uniform. The default value is 10 ticks.
Sets the half life in ticks for the transition time for the [`eyeBrightnessSmooth`](/reference/uniforms/camera#eyebrightnesssmooth) uniform. The default value is 10 ticks.
2 changes: 1 addition & 1 deletion src/content/docs/reference/Constants/wetnessHalflife.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ sidebar:

#### Location: any glsl file

Sets the half life in ticks for the transition from wet to dry weather for the [`wetness`](/reference/uniforms/general/wetness) uniform. The default value is 600 ticks.
Sets the half life in ticks for the transition from wet to dry weather for the [`wetness`](/reference/uniforms/world#wetness) uniform. The default value is 600 ticks.
2 changes: 1 addition & 1 deletion src/content/docs/reference/Macros/MC_HAND_DEPTH.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sidebar:

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

The multiplier is applied in clip space automatically through the [projection matrix](/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](/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:

```glsl
float screenDepth = texture(depthtex0, texcoord).r;
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/reference/Macros/Render_Stages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
order: 1
---

The uniform [`renderStage`](/reference/uniforms/general/renderstage) stores the "render stage" of the current geometry. This can be used to identify what type of geometry is being rendered in more detail than the [gbuffer program](/reference/programs/gbuffers) it's running in. The following render stages are defined by Iris as preprocessor macros:
The uniform [`renderStage`](/reference/uniforms/rendering#renderstage) stores the "render stage" of the current geometry. This can be used to identify what type of geometry is being rendered in more detail than the [gbuffer program](/reference/programs/gbuffers) it's running in. The following render stages are defined by Iris as preprocessor macros:

| define | Description |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
order: 1
---

The `block.properties` file (located in the `shaders` folder) lets you assign IDs to specific blocks/block entities by their Minecraft ID. These IDs can be read through [`mc_Entity`](/reference/attributes/mc_entity) and [`blockEntityId`](/reference/uniforms/general/blockentityid) respectively in [gbuffers](/reference/programs/gbuffers) and [shadow](/reference/programs/shadow) shaders. The `block.properties` file should be placed in the `shaders` folder.
The `block.properties` file (located in the `shaders` folder) lets you assign IDs to specific blocks/block entities by their Minecraft ID. These IDs can be read through [`mc_Entity`](/reference/attributes/mc_entity) and [`blockEntityId`](/reference/uniforms/id#blockentityid) respectively in [gbuffers](/reference/programs/gbuffers) and [shadow](/reference/programs/shadow) shaders. The `block.properties` file should be placed in the `shaders` folder.

Blocks and block entities can be assigned to an ID in this file, with the following syntax:
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:
order: 1
---

The `entity.properties` file lets you assign IDs to specific entities by their Minecraft ID. These IDs can be read through [`entityId`](/reference/uniforms/general/entityid) in [gbuffers](/reference/programs/gbuffers) and [shadow](/reference/programs/shadow) shaders. The `entity.properties` file should be placed in the `shaders` folder.
The `entity.properties` file lets you assign IDs to specific entities by their Minecraft ID. These IDs can be read through [`entityId`](/reference/uniforms/id#entityid) in [gbuffers](/reference/programs/gbuffers) and [shadow](/reference/programs/shadow) shaders. The `entity.properties` file should be placed in the `shaders` folder.

Entities can be assigned to an ID in this file, with the following syntax:
```
Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/reference/Miscellaneous/item_properties.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ Armor trim can be assigned with `trim_<material>`, for example `trim_emerald`.
### Reading IDs

The ID can be read in two different ways for different contexts.
- [`heldItemId`](/reference/uniforms/general/helditemid)/[`heldItemId2`](/reference/uniforms/general/helditemid2) for the currently held item, accessible anywhere.
- [`currentRenderedItemId`](/reference/uniforms/general/currentrendereditemid) for the currently rendering item/armor/trim (including item frames, armor stands, players, etc), accessible in [gbuffers](/reference/programs/gbuffers) and [shadow](/reference/programs/shadow) shaders.
- [`heldItemId`](/reference/uniforms/id#helditemid)/[`heldItemId2`](/reference/uniforms/id#helditemid2) for the currently held item, accessible anywhere.
- [`currentRenderedItemId`](/reference/uniforms/id#currentrendereditemid) for the currently rendering item/armor/trim (including item frames, armor stands, players, etc), accessible in [gbuffers](/reference/programs/gbuffers) and [shadow](/reference/programs/shadow) shaders.
2 changes: 1 addition & 1 deletion src/content/docs/reference/Programs/shadow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sidebar:

Renders world geometry into the shadow buffers, intended for use in shadow mapping.

This program is similar to the [gbuffers](/reference/programs/gbuffers), except it renders terrain from the perspective of the sun or moon. Additionally there is only one shader file for this pass (for the vertex and fragment stages), so all geometry is rendered in `shadow.vsh` and `shadow.fsh`. The type of geometry rendered can be determined with [`renderStage`](/reference/uniforms/general/renderstage) instead. By default, this program renders in an orthographic perspective, this can be changed with [`shadowMapFov`](/reference/constants/shadowmapfov).
This program is similar to the [gbuffers](/reference/programs/gbuffers), except it renders terrain from the perspective of the sun or moon. Additionally there is only one shader file for this pass (for the vertex and fragment stages), so all geometry is rendered in `shadow.vsh` and `shadow.fsh`. The type of geometry rendered can be determined with [`renderStage`](/reference/uniforms/rendering#renderstage) instead. By default, this program renders in an orthographic perspective, this can be changed with [`shadowMapFov`](/reference/constants/shadowmapfov).


## Additional Shadow Programs (Iris 1.8+)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sidebar:

#### Location: shaders.properties

This directive is used to control the alpha test for cutout programs. For the compatibility profile the alpha test is applied automatically when using `gl_FragData` or `gl_FragColor`. For the newer syntax, only the reference value is passed through [`alphaTestRef`](/reference/uniforms/general/alphatestref) and the function must be implemented by the shader.
This directive is used to control the alpha test for cutout programs. For the compatibility profile the alpha test is applied automatically when using `gl_FragData` or `gl_FragColor`. For the newer syntax, only the reference value is passed through [`alphaTestRef`](/reference/uniforms/rendering#alphatestref) and the function must be implemented by the shader.

Replace:
- `<program>` with a gbuffers program name, including the dimension folder if relevant (e.g. `world0/composite2`). This does not work with Iris custom dimensions however.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ sidebar:

#### Location: shaders.properties

Sets a fallback for older shaders which don't support main and alt hands. If `oldHandLight` is set to `true`, [`heldBlockLightValue`](/reference/uniforms/general/heldblocklightvalue) will take the value of the highest light value. The default value is `true` due to legacy support, so it must be specifically disabled to have independent main and alt hand light values.
Sets a fallback for older shaders which don't support main and alt hands. If `oldHandLight` is set to `true`, [`heldBlockLightValue`](/reference/uniforms/id#heldblocklightvalue) will take the value of the highest light value. The default value is `true` due to legacy support, so it must be specifically disabled to have independent main and alt hand light values.
Loading

0 comments on commit b254104

Please sign in to comment.