Skip to content

Commit 5df0e24

Browse files
committed
2 parents d214453 + 7b64e34 commit 5df0e24

File tree

14 files changed

+102
-86
lines changed

14 files changed

+102
-86
lines changed

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,3 @@ PR's May take a while to be added, as they need to be fully verified, and someon
102102

103103
## Translations (i18n)
104104
Translations are not yet supported, but once the english version is complete we will begin building out the languages.
105-
106-
## Contributors
107-
- [Iris Docs](https://github.com/IrisShaders/ShaderDoc/tree/master) - Most of the early documentation
108-
- WhyFencePost / WhyFenceCode - The page and a lot of the data transfer
109-
- NinjaMike - Many uniforms including Iris exclusive uniforms, constants, shaders.properties, programs
110-
- jbritain - Some uniforms, other miscellaneous things
111-
- kloppi417 - editor

src/content/docs/current/Reference/Attributes/at_tangent.mdx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ sidebar:
1212

1313
---
1414

15-
The tangent vector in model space. The `xyz` components store the tangent, and the `w` component stores the handedness of normal/tangent. The handedness should be used to invert the bitangent in cases where a texture is mirrored and the cross product of the normal and tangent vectors would produce an inverted bitangent vector. For example:
16-
```glsl
17-
vec3 normal = normalMatrix * vaNormal;
18-
vec3 tangent = normalMatrix * at_tangent.xyz;
15+
The `xyz` components store an approximation of the current tangent vector in model space, and the sign of the `w` component the handedness of the normal/tangent.
16+
17+
:::note
18+
`at_tangent.xyz` is not guaranteed to be normalized, and `at_tangent.w` is only guaranteed to be in the range `[-1.0, 1.0]` and not zero.
19+
:::
1920

20-
vec3 bitangent = cross(tangent, normal) * at_tangent.w;
21+
The handedness should be used to invert the bitangent in cases where a texture is mirrored and the cross product of the normal and tangent vectors would produce an inverted bitangent vector. For example, in [view space](/current/how-to/coordinate_spaces/):
22+
```glsl
23+
vec3 normal = normalMatrix * normalize(vaNormal);
24+
vec3 tangent = normalMatrix * normalize(at_tangent.xyz);
25+
```
26+
```glsl
27+
vec3 normal = gl_NormalMatrix * normalize(gl_Normal);
28+
vec3 tangent = gl_NormalMatrix * normalize(at_tangent.xyz);
2129
```
2230
```glsl
23-
vec3 normal = gl_NormalMatrix * gl_Normal;
24-
vec3 tangent = gl_NormalMatrix * at_tangent.xyz;
31+
const float inf = uintBitsToFloat(0x7f800000u);
32+
float handedness = clamp(at_tangent.w * inf, -1.0, 1.0); // -1.0 when at_tangent.w is negative, and 1.0 when it's positive
2533
26-
vec3 bitangent = cross(tangent, normal) * at_tangent.w;
34+
vec3 bitangent = cross(tangent, normal) * handedness;
2735
```

src/content/docs/current/Reference/Attributes/mc_Entity.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ sidebar:
1212

1313
---
1414

15-
The `x` component stores the block ID which was assigned to the current block in [`block.properties`](/current/reference/miscellaneous/block_properties/). If an ID for the current block is not defined, a value of `-1` is sent.
15+
The `x` component stores the block ID which was assigned to the current block in [`block.properties`](/current/reference/miscellaneous/block_properties/). If an ID for the current block is not defined, a value of `-1.0` is sent.
1616

17-
:::tip
18-
Iris 1.3 and later (as well as OptiFine) uses a signed short for `mc_Entity`, meaning they can store IDs from `-32768` to `32767`. Older Iris versions do not support negative values, and will send the maximum unsigned value,`65535`, for any blocks with unassigned IDs.
17+
:::note
18+
OptiFine uses a signed short (16-bit two's complement integer) for `mc_Entity.x`, meaning it can store IDs in the range `[-32768, 32767]`. This matches behavior in Iris [1.3, 1.8), while earlier Iris versions used a 16-bit unsigned integer with a range of `[0, 65535]` and its maximum value for blocks with unassigned IDs, instead of `-1.0`. **Iris versions 1.8 and later use a 31-bit unsigned integer, offset by `-1`. This means that `mc_Entity.x` can store IDs in the range `[-1, 2147483646]`, not accounting for IEEE-754 precision limitations.**
19+
20+
Though the vertex attribute data for `mc_Entity.x` is stored as an integer in Iris 1.8+, it is always cast to a `float` before reading. This comes with significant precision issues at high values, `>= 1.0` at values `>= 16777217.0`.
1921
:::
2022

21-
When [`block.properties`](/current/reference/miscellaneous/block_properties/) is not present in the shader pack files, block IDs are assigned according to their pre 1.13 numerical values, as described in the [Minecraft Wiki](https://minecraft.wiki/w/Java_Edition_data_values/Pre-flattening/#Block_IDs). This is intended for legacy purposes, and should not be used for new shader packs.
23+
When [`block.properties`](/current/reference/miscellaneous/block_properties/) isn't present in the shader pack files, block IDs are assigned according to their pre-Minecraft 1.13 numerical values, as described in the [Minecraft Wiki](https://minecraft.wiki/w/Java_Edition_data_values/Pre-flattening/#Block_IDs). This is intended for legacy purposes, and should not be used for new shader packs.
2224

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

25-
This attribute is only available for terrain. For other types of geometry, see [`entityid`](/current/reference/uniforms/id/#entityid) and [`blockentityid`](/current/reference/uniforms/id/#blockentityid).
27+
This attribute is only available for terrain. For other types of geometry, see [`entityid`](/current/reference/uniforms/id/#entityid) and [`blockentityid`](/current/reference/uniforms/id/#blockentityid).

src/content/docs/current/Reference/Attributes/vaNormal.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ This attribute only works with the `core` profile in Minecraft 1.17 and newer. I
2121

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

24-
The normal vector from `vaNormal` is in model space (which varies for different geometry). It can be converted to view space using [`normalMatrix`](/current/reference/uniforms/matrices/#normalmatrix) (or `gl_NormalMatrix` in the compatibility profile).
24+
:::note
25+
The vector is not guaranteed to be normalized.
26+
:::
27+
28+
The normal vector from `vaNormal` is approximate, and in model space (which varies for different geometry). It can be converted to view space using [`normalMatrix`](/current/reference/uniforms/matrices/#normalmatrix) (or `gl_NormalMatrix` in the compatibility profile).
2529
```glsl
26-
vec3 normal = normalMatrix * vaNormal;
30+
vec3 normal = normalMatrix * normalize(vaNormal);
2731
```
2832
```glsl
29-
vec3 normal = gl_NormalMatrix * gl_Normal;
33+
vec3 normal = gl_NormalMatrix * normalize(gl_Normal);
3034
```

src/content/docs/current/Reference/Buffers/colortex.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Additionally, you can read and write to the first 6 colortex buffer in OptiFine
2626
These buffers default to the display resolution, although this can be configured with the [`size.buffer`](/current/reference/shadersproperties/rendering/#sizebuffer) define in shaders.properties. However, changing the buffer size will prevent any [`gbuffer`](/current/reference/programs/gbuffers/) program from writing to the texture.
2727

2828
#### Format / precision
29-
These buffers all default to `RGBA` format (which is `RGBA8` on most systems), but this can be configured as described in the [Texture Formats](/current/reference/buffers/image_format/) section.
29+
These buffers all default to `RGBA` format (which is `RGBA8` on most systems), but this can be configured as described in the [Image Format](/current/reference/buffers/image_format/) section.
3030

3131
#### Clearing
3232

@@ -55,5 +55,5 @@ The first 8 colortex buffers have legacy aliases, although their names are often
5555
| colortex7 | gaux4 |
5656

5757
:::note
58-
If `gdepth` is defined anywhere in the shader and the texture format for `colortex1`/`gdepth` is `RGBA` (or not specifically set by the shader), Iris will upgrade the format to `RGBA32F`. This represents legacy behavior, where `gdepth` was used to store depth values.
58+
If `gdepth` is defined anywhere in the shader and the image format for `colortex1`/`gdepth` is `RGBA` (or not specifically set by the shader), Iris will upgrade the format to `RGBA32F`. This represents legacy behavior, where `gdepth` was used to store depth values.
5959
:::

src/content/docs/current/Reference/Buffers/custom_images.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ To declare a custom image, use the following in shaders.properties:
2626
Replace:
2727
- `<imageName>` with the variable name of the image
2828
- `<samplerName>` with the variable name of the sampler
29-
- `<format>` with the [pixel format](/current/reference/buffers/image_format/) of the image (see "Pixel Formats" section)
30-
- `<internalFormat>` with the [texture format](/current/reference/buffers/image_format/) of the image (see "Texture Format" section)
31-
- `<pixelType>` with the [pixel type](/current/reference/buffers/image_format/) of the image (see "Pixel Types" section)
29+
- `<format>` with the [pixel format](/current/reference/buffers/image_format/) of the image
30+
- `<internalFormat>` with the [image format](/current/reference/buffers/image_format/) of the image
31+
- `<pixelType>` with the [pixel type](/current/reference/buffers/image_format/) of the image
3232
- `<shouldClearOnNewFrame>` with `true` to clear the image after each frame, or `false` to retain data between frames
3333
- `<isRelative>` with `true` to make the image dimensions relative to the screen dimensions, or `false` to make the dimensions absolute
3434
- `<relativeX/absoluteX>` with the relative (floating point) or absolute (integer) size in the x dimension

src/content/docs/current/Reference/Buffers/custom_textures.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ Atlas textures (such as the block atlas) can be loaded by passing their file pat
2929
Additionally, the lightmap dynamic texture can be loaded using either `minecraft:dynamic/lightmap_1` or `minecraft:dynamic/light_map_1`. This texture is equivalent to the `lightmap` sampler used in [gbuffers](/current/reference/programs/gbuffers/). For example `texture.prepare.colortex2 = minecraft:dynamic/lightmap_1` loads the lightmap into `colortex2`.
3030

3131
#### Raw textures
32-
Raw textures can be loaded from the shader files, similarly to image files. However raw textures are uncompressed binary files, where the bytes represent the values in the texture directly. Raw files can also encode 3D textures, and the texture format can be directly controlled (images are always loaded as RGBA8). To use a raw texture, add the following parameters to the custom texture directive:
32+
Raw textures can be loaded from the shader files, similarly to image files. However raw textures are uncompressed binary files, where the bytes represent the values in the texture directly. Raw files can also encode 3D textures, and the image format can be directly controlled (PNG images are always loaded as RGBA8). To use a raw texture, add the following parameters to the custom texture directive:
3333

3434
```properties title="shaders.properties" ins="<type> <internalFormat> <dimensions> <pixelFormat> <pixelType>"
3535
texture.<stage>.<bufferName> = <path> <type> <internalFormat> <dimensions> <pixelFormat> <pixelType>
3636
```
3737

3838
Replace:
3939
- `<type>` with one of the following: `TEXTURE_1D`, `TEXTURE_2D`, `TEXTURE_3D`, or `TEXTURE_RECTANGLE`.
40-
- `<internalFormat>` with the [texture format](/current/reference/buffers/image_format/).
40+
- `<internalFormat>` with the [image format](/current/reference/buffers/image_format/).
4141
- `<dimensions>` with the fixed size dimensions of the texture (the number of components depends on the type).
42-
- `<pixelFormat>` with the pixel format described in the "Pixel Formats" section of the [texture format section](/current/reference/buffers/image_format/).
43-
- `<pixelType>` with the pixel type described in the "Pixel Types" section of the [texture format section](/current/reference/buffers/image_format/).
42+
- `<pixelFormat>` with the [pixel format](/current/reference/buffers/image_format/).
43+
- `<pixelType>` with the [pixel type](/current/reference/buffers/image_format/).
4444

4545

4646
### PBR textures

src/content/docs/current/Reference/Buffers/image_format.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Unsigned normalized buffers support values from 0.0 to 1.0 (inclusive).
3737
| `R16` | 1×16 | `RED` | `UNSIGNED_SHORT` | ✔️ | |
3838
| `R8` | 1×8 | `RED` | `UNSIGNED_BYTE` | ✔️ | |
3939
| `RGBA2`* | 4×2 | `RGBA` | || |
40-
| `R3_G3_B2` | 3/3/2 | `RED` | `UNSIGNED_BYTE_2_3_3_REV` || |
40+
| `R3_G3_B2` | 3/3/2 | `RGB` | `UNSIGNED_BYTE_2_3_3_REV` || |
4141

4242
<sup>*Requires Iris 1.8+</sup>
4343

src/content/docs/current/Reference/Buffers/shadowcolor.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Additionally, you can read and write to `shadowcolor0` and `shadowcolor1` using
2222
These buffers default to the shadow pass resolution, which can be controlled with the [`shadowMapResolution`](/current/reference/constants/shadowmapresolution/) constant.
2323

2424
#### Format / precision
25-
These buffers default `RGBA` format (which defaults to `RGBA8` on most systems), but this can be configured as described in the [Texture Formats](/current/reference/buffers/image_format/) section.
25+
These buffers default `RGBA` format (which defaults to `RGBA8` on most systems), but this can be configured as described in the [Image Format](/current/reference/buffers/image_format/) section.
2626

2727
#### Clearing
2828
By default these buffers clear their values after each frame to solid white (`vec4(1.0, 1.0, 1.0, 1.0)`). This behavior can be configured with the [`shadowcolorNClear`](/current/reference/constants/buffer_clear/) directive, and the clear color can be configured with the [`shadowcolorNClearColor`](/current/reference/constants/buffer_clear_color/) directive.

src/content/docs/current/Reference/Constants/buffer_format.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ sidebar:
1212

1313
---
1414

15-
This directive allows a shader pack to specify the format and precision of a [colortex](/current/reference/buffers/colortex/) or [shadowcolor](/current/reference/buffers/shadowcolor/) color attachment. Replace `<bufferName>` with the name of the color attachment (i.e. `colortex2`, `shadowcolor0`, etc) and `format` with the format as described in the [Texture Formats](/current/reference/buffers/image_format/) section.
15+
This directive allows a shader pack to specify the format and precision of a [colortex](/current/reference/buffers/colortex/) or [shadowcolor](/current/reference/buffers/shadowcolor/) color attachment. Replace `<bufferName>` with the name of the color attachment (i.e. `colortex2`, `shadowcolor0`, etc) and `format` with the [image format](/current/reference/buffers/image_format/).
1616

1717
This directive only needs to be defined once in the shader pack, can can be defined in (mostly) any shader file. Because the format names are not defined as part of glsl, the directive must either be put in a block comment, or the format name must be otherwise manually defined to any value to avoid compilation errors. Do not put the directive in a single line comment, or have any other text in the line of the directive, as this may cause it to not be detected properly.

0 commit comments

Comments
 (0)