Skip to content

Commit

Permalink
Merge pull request #229 from ninjamike1211/main
Browse files Browse the repository at this point in the history
feat: Directives/Constants: Added remaining const directives
  • Loading branch information
ninjamike1211 authored Jun 4, 2024
2 parents 762f0eb + 3c4b222 commit 1c11339
Show file tree
Hide file tree
Showing 17 changed files with 185 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/content/docs/reference/Buffers/noisetex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ sidebar:

### `uniform sampler2D noisetex;`

This buffer stores a generated RGB white noise texture. The resolution of this texture can be configured with the `const int noiseTextureResolution` constant, and defaults to 256x256. The texture is always square, meaning its width and height are equal.
This buffer stores a generated RGB white noise texture. The resolution of this texture can be configured with the [`noiseTextureResolution`](/reference/directives/constants/noisetextureresolution) constant, and defaults to 256x256. The texture is always square, meaning its width and height are equal.
5 changes: 5 additions & 0 deletions src/content/docs/reference/Buffers/shadowtex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ These buffers are written to by [`shadow`](/reference/programs/shadow) program,

These buffers only store information in a single channel, the red component. The shadow buffer precision is hardware/driver dependent, however most hardware uses either 24-bit or 32-bit precision. The resolution of the shadow pass can be controlled with the `shadowMapResolution` constant.

#### Hardware Sampling
[`shadowHardwareFiltering`](/reference/directives/constants/shadowhardwarefiltering) enables support hardware sampling (depth comparison mode) for hardware shadow filtering. This turns the shadowtex samplers into `sampler2DShadow` samplers, which when sampled take the full xyz coordinates of the shadow position. The passed z coordinate is then compared to the values in the buffer around the xy coordinate, and the result is the weighted average of these comparisons. This produces a filtering effect on the shadow with very little to no performance impact. More information can be found in the [Khronos Wiki](https://www.khronos.org/opengl/wiki/Sampler_Object#Comparison_mode).

When hardware sampling is used, the texture read no longer returns the distance stored in the buffer, but the result of a filtering depth comparison. This prevents its use in algorithms such as PCSS that rely on the actual value stored in the buffer. However Iris enables the use of separate buffers for hardware sampling, `shadowtex0HW` and `shadowtex1HW`, while retaining the original functionality on the base shadowtex buffers. This requires the [`SEPARATE_HARDWARE_SAMPLERS`](/reference/directives/shadersproperties/flags) feature flag as well as setting [`shadowHardwareFiltering`](/reference/directives/constants/shadowhardwarefiltering) to true.

#### Legacy Aliases
The alias `waterShadow` points to the same buffer as `shadowtex0`. If `waterShadow` is present anywhere in the code, then the alias `shadow` will point to the same buffer as `shadowtex1`, otherwise it will point to the buffer `shadowtex0`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: ambientOcclusionLevel
description: ambientOcclusionLevel
sidebar:
label: ambientOcclusionLevel
order: 3
---

### `const float ambientOcclusionLevel = 1.0;`

#### Location: any glsl file

Sets the amount of vanilla ambient occlusion (AO) that is applied through the color vertex attribute. The default value is `1.0` (vanilla level), setting it to `0.0` will disable vanilla AO. Valid range for this value is `[0.0 - 1.0]`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: centerDepthHalflife
description: centerDepthHalflife
sidebar:
label: centerDepthHalflife
order: 3
---

### `const float centerDepthHalflife = 1.0;`

#### 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: drynessHalflife
description: drynessHalflife
sidebar:
label: drynessHalflife
order: 3
---

### `const float drynessHalflife = 200.0;`

#### 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: eyeBrightnessHalflife
description: eyeBrightnessHalflife
sidebar:
label: eyeBrightnessHalflife
order: 3
---

### `const float eyeBrightnessHalflife = 10.0;`

#### 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: noiseTextureResolution
description: noiseTextureResolution
sidebar:
label: noiseTextureResolution
order: 3
---

### `const int noiseTextureResolution = 256;`

#### Location: any glsl file

Sets the resolution for [`noisetex`](/reference/buffers/noisetex). This texture is always square, so the value applies to both x and y axes. The default value is 256.
15 changes: 15 additions & 0 deletions src/content/docs/reference/Directives/Constants/shadowDistance.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: shadowDistance
description: shadowDistance
sidebar:
label: shadowDistance
order: 3
---

### `const float shadowDistance = 160.0;`

#### Location: any glsl file

Sets the radius of the [shadow pass](/reference/programs/shadow) in blocks. The default value is 160 blocks.

By default this does not cull geometry outside that distance, only applying a scaling factor to the shadow projection matrix. However setting [`shadowDistanceRenderMul`](/reference/directives/constants/shadowdistancerendermul) to a positive value will apply culling.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: shadowDistanceRenderMul
description: shadowDistanceRenderMul
sidebar:
label: shadowDistanceRenderMul
order: 3
---

### `const float shadowDistanceRenderMul = -1.0;`

#### Location: any glsl file

Sets the culling distance multiplier for the [shadow pass](/reference/programs/shadow).

By default this value is `-1`, which means geometry outside the [`shadowDistance`](/reference/directives/constants/shadowdistance) are not culled. Setting this to a positive value applies culling to geometry outside `shadowDistance * shadowDistanceRenderMul` blocks from the camera. For example, `1.0` culls outside [`shadowDistance`](/reference/directives/constants/shadowdistance), `0.5` culls outside half of [`shadowDistance`](/reference/directives/constants/shadowdistance), and `2.0` culls outside twice [`shadowDistance`](/reference/directives/constants/shadowdistance). `shadowDistanceRenderMul` has no effect on the scale of geometry in the [shadow pass](/reference/programs/shadow).
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: shadowHardwareFiltering
description: shadowHardwareFiltering
sidebar:
label: shadowHardwareFiltering
order: 3
---

### `const bool shadowHardwareFiltering = true;`

#### Location: any glsl file

Enables hardware shadow sampling (depth comparison mode) for [`shadowtex`](/reference/buffers/shadowtex) buffers. See [Hardware Sampling](/reference/buffers/shadowtex) for more info.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: shadowIntervalSize
description: shadowIntervalSize
sidebar:
label: shadowIntervalSize
order: 3
---

### `const float shadowIntervalSize = 1.0;`

#### Location: any glsl file

Sets the snapping interval for the [shadow pass](/reference/programs/shadow) in blocks.

By default the [shadow pass](/reference/programs/shadow) "snaps" geometry to the block grid, which means at the player moves, the geometry in the shadow pass only shifts when the player crosses the boundary between blocks. This is done to reduce visual jittering/noise in the shadows when moving. This interval can be configured with `shadowIntervalSize` (e.g. `2.0` would snap to every other block, `0.5` snaps to every half block), or disabled outright by setting the value to `0.0`.
15 changes: 15 additions & 0 deletions src/content/docs/reference/Directives/Constants/shadowMapFov.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: shadowMapFov
description: shadowMapFov
sidebar:
label: shadowMapFov
order: 3
---

### `const float shadowMapFov = 90.0;`

#### Location: any glsl file

Sets the FOV (field of view) for the shadow pass.

By default the shadow map uses orthographic rendering, which produces directional shadows which don't appear to come from a single point but instead a direction. Setting the FOV value however will change the rendering to a projection similar to the primary scene camera. This can be used to produce projected scene-like rendering similar to the [gbuffers](/reference/programs/gbuffers) programs, but from the [shadow pass](/reference/programs/shadow).
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: shadowMapResolution
description: shadowMapResolution
sidebar:
label: shadowMapResolution
order: 3
---

### `const int shadowMapResolution = 1024;`

#### Location: any glsl file

Sets the resolution for [`shadowtex`](/reference/buffers/shadowtex) and [`shadowcolor`](/reference/buffers/shadowcolor) buffers used in the [shadow pass](/reference/programs/shadow). These buffers are always square, so the value applies to both x and y axes. The default value is 1024.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: sunPathRotation
description: sunPathRotation
sidebar:
label: sunPathRotation
order: 3
---

### `const float sunPathRotation = 0.0;`

#### Location: any glsl file

Sets the angle rotation in degrees of the sun/moon perpendicular to their direction of travel. The default value of `0.0` has the sun/moon travel in the highest arch directly over the top of the sky dome. A larger value (negative or positive) will rotate that path such that it does not cross directly over the top of the sky dome.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: wetnessHalflife
description: wetnessHalflife
sidebar:
label: wetnessHalflife
order: 3
---

### `const float wetnessHalflife = 600.0;`

#### 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.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ sidebar:

### `uniform float centerDepthSmooth;`

This uniform stores the value in the depth buffer `depthtex0` at the center of the screen, smoothed over time. The speed of the smoothing can be controlled with `centerDepthSmoothHalflife`, a `const` `float` which stores the transition halflife in ticks.
This uniform stores the value in the depth buffer `depthtex0` at the center of the screen, smoothed over time. The speed of the smoothing can be controlled with [`centerDepthHalflife`](/reference/directives/constants/centerdepthhalflife).
2 changes: 1 addition & 1 deletion src/content/docs/reference/Uniforms/General/wetness.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ sidebar:
### `uniform float wetness;`

This uniform outputs the current strength of rain and is non-zero when there is currently a rain storm (e.g. weather set rain). The value ranges between `0` to `1` where `0` means no rain and `1` means rain storm, the value is interpolated between those values during transitions in weather.
The transition is significantly slower, and can be controlled with `wetnessHalfLife`.
The transition is significantly slower, and can be controlled with [`wetnessHalfLife`](/reference/directives/constants/wetnesshalflife).

See also - [`rainStrength`](/reference/uniforms/general/rainstrength)

0 comments on commit 1c11339

Please sign in to comment.