Skip to content

Commit d32d394

Browse files
authored
Merge pull request #351 from kloppi417/standardization
Standardization changes
2 parents 2d2b22a + 8360d70 commit d32d394

File tree

105 files changed

+820
-534
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+820
-534
lines changed

README.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,45 @@ Unfinished/Unfinished docs are marked with the `Unfinished` tag in the warning s
3737

3838
Write in your own way, and try to use existing pages or ask before adding new ones. For how to write content, follow the guides on [https://diataxis.fr/](https://diataxis.fr/).
3939

40-
### Dictionary:
41-
42-
- Please use full terms, no shortening. EX no `complementary -> comp`.
43-
- Refer to shader packs as `pack` and/ or `packs`.
44-
- If referring to worlds (`world0` and the like), use this syntax: Overworld(`world0`)
40+
### Style Guide
41+
42+
- Use proper capitalization. Common mistakes include:
43+
- `Optifine` (should be `OptiFine`)
44+
- `glsl` (should be `GLSL`)
45+
- Use the correct text stylization:
46+
- Backticks (\`) should be used for any term used exactly in code (ex: `uniform`)
47+
- For colortex buffers, only use backticks if the number is included (ex: `colortex5`)
48+
- For gbuffers, just kinda vibe it, I don't have a definitive rule here
49+
- Bold (\*\*) should be used for any term not used in code (ex: **attributes**)
50+
- Italics (\*) may be used for emphasis
51+
- Use full terms, no shortening. (ex: no `complementary -> comp`.)
52+
- Something specific to a specific type of shader (vertex, fragment, etc) should include the file extension (ex: `gbuffers_water.fsh`)
53+
- Use wildcard notation (`*`) to indicate multiple files (ex: `gbuffers_*.fsh` refers to all fragment shaders in a`gbuffers` program)
54+
- Something valid for all shader types should omit an extension (ex: `final`)
55+
- Refer to shader packs as `shader pack(s)`.
56+
- Refer to texture/resource packs as `resource pack(s)`
57+
- Use `rgba` for swizzling only when explicitly related to color channels, otherwise use `xyzw`
4558
- Make headings as succinct as possible to help the reader quickly find the content they need
4659
- Use simple present tense for verbs
4760

48-
### Guides:
49-
Guides walk the user through completing a task (EX creating their first shader). A guide should lead from one outcome to another, and is a multi lesson system of teaching (defined by their folder with multiple pages). They are to be written in a style similar to [tutorials on Diataxis](https://diataxis.fr/tutorials/). Guides are open ended.
61+
#### File Structure
62+
- Use `/` to denote folders (as opposed to `\`, which is used on Windows)
63+
- Add a closing `/` to indicate folders, omit to indicate files
64+
- The root directory is assumed to be the Minecraft folder. Ex:
65+
- `/patched_shaders/`
66+
- `/mods/1.21.4/iris-1.7.1+mc1.21.jar`
67+
- For a local directory, omit the starting `/`. Ex:
68+
- `shaders/final.fsh`
69+
70+
### Guides
71+
Guides walk the user through completing a task (e.g. creating their first shader). A guide should lead from one outcome to another, and is a multi lesson system of teaching (defined by their folder with multiple pages). They are to be written in a style similar to [tutorials on Diataxis](https://diataxis.fr/tutorials/). Guides are open ended.
5072

5173
A guide should leave the reader feeling comfortable with the topic, and it should leave them in a way that they are able to experiment by themselves.
5274

53-
### How To:
54-
A how to is a singular short article that walks a user through a small problem in their way (EX transforming shadows to screen space or tonemapping). A how to is made to walk a user through a short section of code and does not need to lead from one outcome to another. It is made to increase/create the understanding on a small section of code, and is rarely open ended. The how to should be written similar to [how to guides on Diataxis](https://diataxis.fr/how-to-guides/).
75+
### How To
76+
A how to is a singular short article that walks a user through a small problem in their way (e.g. transforming shadows to screen space or tonemapping). A how to is made to walk a user through a short section of code and does not need to lead from one outcome to another. It is made to increase/create the understanding on a small section of code, and is rarely open ended. The how to should be written similar to [how to guides on Diataxis](https://diataxis.fr/how-to-guides/).
5577

56-
### Reference:
78+
### Reference
5779
A reference is a docs page. It give objective information on a subject, without moving towards individual use cases. These are often short pages, which are written to provide information about syntax surrounding a line or two of code. These need to be written in a succinct way so that the user can quickly find information. Best practices are located at [references in Diataxis](https://diataxis.fr/current/reference/)
5880

5981
For uniform references please look at `alphaTestRef` for formatting. The aside found there can be used for any version specific stuff.
@@ -85,4 +107,5 @@ Translations are not yet supported, but once the english version is complete we
85107
- [Iris Docs](https://github.com/IrisShaders/ShaderDoc/tree/master) - Most of the early documentation
86108
- WhyFencePost / WhyFenceCode - The page and a lot of the data transfer
87109
- NinjaMike - Many uniforms including Iris exclusive uniforms, constants, shaders.properties, programs
88-
- jbritain - Some uniforms, other miscellaneous things
110+
- jbritain - Some uniforms, other miscellaneous things
111+
- kloppi417 - editor

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
If you've found a vulnerability, we would like to know so we can fix it before it is released publicly. Do not open a GitHub issue for a found vulnerability.
1313

14-
Please join [The Iris Discord](https://discord.gg/jQJnav2jPu) and dm one of the docs developers. Send the details:
14+
Please join [The Iris Discord](https://discord.gg/jQJnav2jPu) and DM one of the docs developers. Send the details:
1515

1616
- where the vulnerability can be observed
1717
- a brief description of the vulnerability

src/content/docs/aperture/migration.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Aperture is a new pipeline for Iris, set to be released with Iris 2.0.
1515
- It uses pipeline code written by shader developers in TypeScript, allowing for fully customizable packs.
1616
- It has a mod API that allows for mods to apply custom vertex formats, vertex transformations, and (basic) fragment warping without interfering with shader developers.
1717
- It has no limits on the number of textures, buffers, or programs you can have, how complex they can be, or how they are running.
18-
- It has a new shadow mapping system based on cascaded shadow maps, allowing shadow maps that reach far beyond what Optifine packs can without distortion.
18+
- It has a new shadow mapping system based on cascaded shadow maps, allowing shadow maps that reach far beyond what OptiFine packs can without distortion.
1919
- Packs written on Aperture use a modern version of OpenGL that can be translated to other API's in the future.
2020

2121
This serves as temporary documentation whilst Aperture is being developed.
@@ -47,7 +47,7 @@ Shader programs are registered in the `setupShader` function with the `registerS
4747

4848
`ObjectShader`s take a `programUsage`, these are predefined for you, for example `TERRAIN_SOLID`.
4949

50-
`Composite` and `Compute` shaders require a `Stage` argument passed to `registerShader` before the shader object itself. This defines when the shader runs - for example `Stage.POST_RENDER` is equivalent to a `composite` pass in the Optifine format.
50+
`Composite` and `Compute` shaders require a `Stage` argument passed to `registerShader` before the shader object itself. This defines when the shader runs - for example `Stage.POST_RENDER` is equivalent to a `composite` pass in the OptiFine format.
5151

5252
To add a vertex and fragment shader to your shader object, you can call `.vertex(<PATH_TO_VERTEX>)` and `.fragment(<PATH_TO_FRAGMENT>)`.
5353

@@ -70,7 +70,7 @@ Vertex shaders should define two functions:
7070
Set `data.clipPos` as you would `gl_Position`. Usually this can just be `iris_projectionMatrix * iris_modelViewMatrix * data.modelPos`
7171

7272
:::note[Info]
73-
`iris_projectionMatrix` and `iris_modelViewMatrix` are patched to make sense for the relevant usage, in the same way `gl_ModelViewMatrix` is in Optifine.
73+
`iris_projectionMatrix` and `iris_modelViewMatrix` are patched to make sense for the relevant usage, in the same way `gl_ModelViewMatrix` is in OptiFine.
7474
:::
7575

7676
#### `void iris_sendParameters(VertexData data)`

src/content/docs/current/How To/coordinate_spaces.mdx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ sidebar:
88

99
At the start of a shader program, the vertex position is provided in the form of `gl_Vertex` (or `VAPosition`). This position is in *model space*. By the time it reaches the fragment shader, the position is in *screen space*. Between these two are a number of other coordinate spaces.
1010

11-
**This page does not cover *clip space*, *NDC space*, or *screen space*, as these are applicable to all 3D graphics, not just Minecraft.** It is recommended that you also read the [LearnOpenGL article on coordinate systems](https://learnopengl.com/Getting-started/Coordinate-Systems) to gain a good understanding of these other spaces. The [shaderLABS Wiki](https://shaderlabs.org/wiki/Coordinate_Spaces) also has an explanation of different types of transformations, as well as an interactive visualiser of the different spaces.
11+
:::note
12+
This page does not cover **clip space**, **NDC space**, or **screen space**, as these are applicable to all 3D graphics, not just Minecraft. It is recommended that you also read the [LearnOpenGL article on coordinate systems](https://learnopengl.com/Getting-started/Coordinate-Systems) to gain a good understanding of these other spaces. The [shaderLABS Wiki](https://shaderlabs.org/wiki/Coordinate_Spaces) also has an explanation of different types of transformations, as well as an interactive visualiser of the different spaces.
13+
:::
1214

1315
## Space Conversion Cheatsheet
1416
This page is designed to be read in tandem with this cheatsheet, which shows every space and how to convert between them.
@@ -18,7 +20,7 @@ This page is designed to be read in tandem with this cheatsheet, which shows eve
1820
## Spaces
1921

2022
### Model Space
21-
In Iris (and Optifine), *model space* is whatever coordinate space the vertex position attribute is sent in. The exact coordinate space varies based on the specific geometry, and has the potential to vary across different Minecraft versions. As a result, it is always recommended to treat *model space* like an unknown space and convert to view space with the `gl_ModelViewMatrix`/[`modelViewMatrix`](/current/reference/uniforms/matrices#modelviewmatrix). *Model space* is also sometimes known as '*local space*'.
23+
In Iris (and OptiFine), **model space** is whatever coordinate space the vertex position attribute is sent in. The exact coordinate space varies based on the specific geometry, and has the potential to vary across different Minecraft versions. As a result, it is always recommended to treat *model space* like an unknown space and convert to view space with the `gl_ModelViewMatrix`/[`modelViewMatrix`](/current/reference/uniforms/matrices#modelviewmatrix). **Model space** is also sometimes known as "**local space**".
2224

2325

2426
If using the core profile (and as such using [`vaPosition`](/current/reference/attributes/vaposition) instead of `gl_Vertex`), the *model space* position for terrain should be offset with [`chunkOffset`](/current/reference/uniforms/rendering#chunkoffset). The conversion sheet assumes this has already been done. Here's an example of what that should look like:
@@ -27,24 +29,24 @@ vec3 model_pos = vaPosition + chunkOffset;
2729
```
2830

2931
### View Space
30-
*View space* is the vertex position relative to the camera. This is also sometimes known as '*eye space*' (not to be confused with '*eye player space*').
32+
*View space* is the vertex position relative to the camera. This is also sometimes known as "**eye space**" (not to be confused with "**eye player space**").
3133

32-
The `x` and `y` components of view space line up with screenspace (negative is left/down, positive is right/up), however the `z` coordinate is "backwards" (forward is negative z).
34+
The `x` and `y` components of view space line up with screen space (negative is left/down, positive is right/up), however the `z` coordinate is "backwards" (forward is negative z).
3335

3436
### Player Space
35-
*Player space* is the vertex position relative to the *camera* (not the player). The difference between view and *player space* is that whilst *view space* directions change based on the camera angle, *player space* directions are constant, aligned to the axes of Minecraft's coordinates. For example, a vector `0.0, 1.0, 0.0` is along the Y axis and as such would be along Minecraft's actual Y axis (upwards).
37+
*Player space* is the vertex position relative to the *camera* (not the player). The difference between view and **player space** is that whilst **view space** directions change based on the camera angle, **player space** directions are constant, aligned to the axes of Minecraft's coordinates. For example, a `vec3(0.0, 1.0, 0.0)` is along the Y axis and as such would be along Minecraft's actual Y axis (upwards).
3638

3739
To get a position which is relative to the actual player model in third person, you can use [`relativeEyePosition`](/current/reference/uniforms/camera#relativeeyeposition).
3840

3941
#### Feet and Eye Player Space
40-
The names of these spaces are misleading, as '*feet player space*' is not in any way related to the player's feet. The difference between the two is that in *feet player space*, the origin remains locked to the player's head position, whereas in *eye player space*, effects like view bobbing are accounted for, meaning that the origin is locked to the camera. This is why the two can be interchanged with the addition and subtraction of [`gbufferModelViewInverse[3]`](/current/reference/uniforms/matrices#gbuffermodelviewinverse) - this fourth component of the matrix accounts for the translation from the player's head to the camera.
42+
The names of these spaces are misleading, as "**feet player space**" is not in any way related to the player's feet. The difference between the two is that in **feet player space**, the origin remains locked to the player's head position, whereas in **eye player space**, effects like view bobbing are accounted for, meaning that the origin is locked to the camera. This is why the two can be interchanged with the addition and subtraction of [`gbufferModelViewInverse[3]`](/current/reference/uniforms/matrices#gbuffermodelviewinverse) - this fourth component of the matrix accounts for the translation from the player's head to the camera.
4143

42-
It is also worth noting that in third person mode, view bobbing is disabled, and as such, *eye* and *feet player space* are *usually* identical.
44+
It is also worth noting that in third person mode, view bobbing is disabled, and as such, eye and feet player space are *usually* identical.
4345

4446
### World Space
45-
*World space* is the vertex position in Minecraft's actual coordinate system. It is directionally equivalent to *player space*, as it is simply the result of offsetting a *feet player space* position by the camera position. This roughly lines up with the game's actual coordinate positions, however [`cameraPosition`](/current/reference/uniforms/camera#cameraposition) resets every 30000 blocks (or every 1000 blocks when teleporting). If the exact Minecraft position is required, [`cameraPositionInt`](/current/reference/uniforms/camera#camerapositionint) and [`cameraPositionFract`](/current/reference/uniforms/camera#camerapositionfract) can be used
47+
**World space** is the vertex position in Minecraft's actual coordinate system. It is directionally equivalent to **player space**, as it is simply the result of offsetting a *feet player space* position by the camera position. This roughly lines up with the game's actual coordinate positions, however [`cameraPosition`](/current/reference/uniforms/camera#cameraposition) resets every 30000 blocks (or every 1000 blocks when teleporting). If the exact Minecraft position is required, [`cameraPositionInt`](/current/reference/uniforms/camera#camerapositionint) and [`cameraPositionFract`](/current/reference/uniforms/camera#camerapositionfract) can be used
4648

4749
## Shadow Space
48-
'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*.
50+
"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**.
4951

50-
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*.
52+
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*.

src/content/docs/current/How To/pbr_standards.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ MC_TEXTURE_FORMAT_LAB_PBR
6060
MC_TEXTURE_FORMAT_LAB_PBR_1_3
6161
```
6262

63-
**Note:** At the time of writing, the only supported LabPBR version is 1.3. **Specifying other versions in a texture pack may cause errors.**
64-
63+
:::caution[Warning]
64+
At the time of writing, the only supported LabPBR version is 1.3. Specifying other versions in a texture pack may cause errors.
65+
:::

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ sidebar:
88

99
### `in vec4 at_midBlock;`
1010

11-
**Valid Programs**: terrain (*gbuffers_terrain*, *gbuffers_water*, *shadow*)
11+
**Valid Programs**: `gbuffers_terrain.vsh`, `gbuffers_water.vsh`, `shadow.vsh`
1212

1313
---
1414

15-
The first three components store the world/player space offset from the vertex's position to the center of the block in 1/64th block units. For example, the center position would be calculated like this:
15+
The `xyz` components store the world/player space offset from the vertex's position to the center of the block in 1/64th block units. For example, the center position would be calculated like this:
1616
```glsl
17-
vec3 centerPosition = position + at_midBlock.xyz/64.0;
17+
vec3 centerPosition = position + at_midBlock.xyz / 64.0;
1818
```
1919

20-
In Iris 1.7 and newer, `at_midBlock.w` stores the light level of the current block (without the influence of nearby light sources, range `0` to `15`). This can be used to tell if a block is emissive. It's recommended to use this together with [`BLOCK_EMISSION_ATTRIBUTE`](/current/reference/shadersproperties/flags).
21-
22-
This attribute (both the mid block offset and the emission value) are only available for terrain.
20+
In Iris 1.7 and newer, the `w` component stores the light level of the current block (without the influence of nearby light sources, range `0` to `15`). This can be used to tell if a block is emissive. It's recommended to use this together with [`BLOCK_EMISSION_ATTRIBUTE`](/current/reference/shadersproperties/flags).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebar:
88

99
### `in vec4 at_tangent;`
1010

11-
**Valid Programs**: all gbuffers/shadow
11+
**Valid Programs**: `gbuffers_*.vsh`, `shadow.vsh`
1212

1313
---
1414

0 commit comments

Comments
 (0)