Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: directives/uniforms: add iris exclusive directives #224

Merged
merged 1 commit into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: entityShadowDistanceMul
description: entityShadowDistanceMul
sidebar:
label: entityShadowDistanceMul
order: 3
badge:
text: Iris Only
variant: tip
---

### `const float entityShadowDistanceMul = 1.0;`

#### Location: composite, deferred, final, prepare

This value controls the bounds for entity shadows to be rendered. By default, it is the value set for terrain. Any floating point number that is not 1 is multiplied by the terrain distance to get the final shadow distance multiplier.
18 changes: 18 additions & 0 deletions src/content/docs/reference/Directives/Constants/voxelDistance.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: voxelDistance
description: voxelDistance
sidebar:
label: voxelDistance
order: 3
badge:
text: Iris Only
variant: tip
---

### `const float voxelDistance = 160.0;`

#### Location: composite, deferred, final, prepare

Setting [`shadow.culling = reversed`](/reference/directives/shadersproperties/shadow_culling) in shaders.properties will create an area around the player where geometry in the shadow pass will not be culled. Outside this area, geometry will be culled as if shadow culling was enabled. This "unculled" distance is controled with `const float voxelDistance`, and the culled distance is controlled as normal with `const float shadowDistance` (and cannot be lower than `voxelDistance`). This feature is intended for packs which utilize both voxelization and a shadow map.

It is also recommended (but not required) to use the feature flag [`REVERSED_CULLING`](/reference/directives/shadersproperties/flags) to avoid compatibility issues with older Iris versions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ iris.features.optional=BLOCK_EMISSION_ATTRIBUTE ENTITY_TRANSLUCENT SSBO

The following are currently valid options:

`SEPARATE_HARDWARE_SAMPLERS` (required for Separate Hardware Shadow Samplers)
`SEPARATE_HARDWARE_SAMPLERS` (required for [Separate Hardware Shadow Samplers](/reference/buffers/shadowtex))

`PER_BUFFER_BLENDING`

Expand All @@ -33,8 +33,8 @@ The following are currently valid options:

`CUSTOM_IMAGES` (required for Custom Images)

`HIGHER_SHADOWCOLOR` (required for Extended Shadowcolor)
`HIGHER_SHADOWCOLOR` (required for [Extended Shadowcolor](/reference/buffers/shadowcolor))

`REVERSED_CULLING` (recommended, but not required for Reverse Shadow Culling)
`REVERSED_CULLING` (recommended, but not required for [Reverse Shadow Culling](/reference/directives/constants/voxeldistance))

`BLOCK_EMISSION_ATTRIBUTE` (recommended, but not required for [Block Emission: at_midBlock.w] as of [iris-1.7.0-snapshotmc1.20.4-a787322])
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: particles.ordering
description: particles.ordering
sidebar:
label: particles.ordering
order: 2
badge:
text: Iris Only
variant: tip
---

### `particles.ordering=<mixed|after|before>`

#### Location: shaders.properties

This controls how particles will be rendered. There are 3 possible options for this value.

- `mixed`: Opaque particles are rendered before the [deferred](/reference/programs/deferred) pass, and translucent particles are rendered after. This is the default if no [deferred](/reference/programs/deferred) passes are present.
- `after`: All particles are rendered after the [deferred](/reference/programs/deferred) pass. This is the default if there are any [deferred](/reference/programs/deferred) passes.
- `before`: All particles are rendered before the [deferred](/reference/programs/deferred) pass.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: separateEntityDraws
description: separateEntityDraws
sidebar:
label: separateEntityDraws
order: 2
badge:
text: Iris Only
variant: tip
---

### `separateEntityDraws=<true|false>`

#### Location: shaders.properties

If `separateEntityDraws` is true in shaders.properties, translucent entities and block entities will wait to be drawn until after the deferred pass, and then will be drawn in the `gbuffers_entities_translucent` and `gbuffers_block_translucent` programs.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: shadow.culling
description: shadow.culling
sidebar:
label: shadow.culling
order: 2
---

### `shadow.culling=<true|false|reversed>`

#### Location: shaders.properties

Controls culling in the [`shadow`](/reference/programs/shadow) pass. Enabling it will prevent geometry which would not cast a shadow through the view frustum from rendering. Disabling it will prevent any geometry within the shadow distance from being culled.

Iris adds an additional option, `reversed`, which disables culling within a specific radius of the player as defined in [`voxelDistance`](/reference/directives/constants/voxeldistance), while retaining culling outside of that distance. It is also recommended (but not required) to use the feature flag [`REVERSED_CULLING`](/reference/directives/shadersproperties/flags) to avoid compatibility issues with older Iris versions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: shadow.enabled
description: shadow.enabled
sidebar:
label: shadow.enabled
order: 2
badge:
text: Iris Only
variant: tip
---

### `shadow.enabled=<true|false>`

#### Location: shaders.properties

Normally Optifine/Iris will check if the shadow buffers are bound and used to determine when to enable/disable the shadow pass. Iris offers an additional explicit control for enabling/disabling the pass. Thic can be useful for voxelization which doesn't write to a [shadowtex](/reference/buffers/shadowtex)/[shadowcolor](/reference/buffers/shadowcolor) buffer (for example SSBOs or custom images).
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: shadowPlayer
description: shadowPlayer
sidebar:
label: shadowPlayer
order: 2
badge:
text: Iris Only
variant: tip
---

### `shadowPlayer=<true|false>`

#### Location: shaders.properties

This value controls if the player should have a shadow rendered. This is forced on if `shadowEntities` (default `true`) is enabled. This also controls shadows of any entities the player is riding.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: supportsColorCorrection
description: supportsColorCorrection
sidebar:
label: supportsColorCorrection
order: 2
badge:
text: Iris Only
variant: tip
---

### `supportsColorCorrection=<true|false>`

#### Location: shaders.properties

Iris 1.6.4 added support for additional color spaces beyond sRGB (DCI_P3, Display P3, REC2020, and Adobe RGB). This does not allow for outputting HDR values, it simply applies a tonemapping operation in the given color space instead of sRGB.

By default, Iris will assume all shaders output sRGB, and if a different color spaces is selected it will convert the sRGB output to that color space for display. If `supportsColorCorrection = true` is in shaders.properties however, this conversion will be left up to the shader. In all scenarios, the chosen colorspace is avaliable through the uniform [`currentColorSpace`](/reference/uniforms/general/currentcolorspace).
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: voxelizeLightBlocks
description: voxelizeLightBlocks
sidebar:
label: voxelizeLightBlocks
order: 2
badge:
text: Iris Only
variant: tip
---

### `voxelizeLightBlocks=<true|false>`

#### Location: shaders.properties

Using `voxelizeLightBlocks` in shaders.properties, you can now voxelize light blocks in the shadow or main pass.

This only applies to light blocks ([Minecraft Wiki](https://minecraft.wiki/w/Light_Block)), which are a specific block which is invisible but emits a specific level of light. This does not affect any other blocks or geometry.

Light blocks will be rendered as a single (degenerate) invisible quad with all points centered on the middle of the block. (`at_midBlock` will be 0.) The ID will correspond as normal to the light block, and UV will be 0. `lmcoord.xy` will both be the value of the light made by the light block.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: currentRenderedItemId
description: currentRenderedItemId
sidebar:
label: currentRenderedItemId
order: 1
badge:
text: Iris Only
variant: tip
---

### `uniform int currentRenderedItemId;`

Iris allows detecting items and armor during rendering on *anything*.

Using `uniform int currentRenderedItemId;`, you can detect items and armor rendered in the level at the point of render. This is similar to [`heldItemId`](/reference/uniforms/general/helditemid) and [`heldItemId2`](/reference/uniforms/general/helditemid2), except it applies to the currently rendered item/armor instead of the held item.

There are some new ID's that can be detected alongside items and armor:

`trim_material` to detect armor trims on armor. (For example, `trim_emerald`).