Skip to content

Commit a556309

Browse files
authored
Merge pull request #352 from IrisShaders/texture-atlases
add texture atlases
2 parents b1ef6e8 + 437764d commit a556309

2 files changed

Lines changed: 67 additions & 12 deletions

File tree

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ Texture packs can optionally provide extra data to Iris through the use of norma
99

1010
## Access
1111

12-
Normal map textures have the same name as the texture they should be attached to, with the `_n` suffix. For example, for a block of cobblestone, the texture is called `cobblestone.png`, and the normal map for cobblestone would be `cobblestone_n.png`. Likewise, specular maps have the suffix `_s`, meaning for cobblestone it would be `cobblestone_s.png`.
12+
Normal and specular map textures are provided by the resource pack. Normal maps have the same name as the texture they should be attached to, with the `_n` suffix. For example, for a block of cobblestone, the texture is called `cobblestone.png`, and the normal map for cobblestone would be `cobblestone_n.png`. Likewise, specular maps have the suffix `_s`, meaning for cobblestone it would be `cobblestone_s.png`.
1313

1414
These textures are provided in the form of two additional texture atlases.
15-
- `uniform sampler2D normals`
16-
- `uniform sampler2D specular`
17-
18-
These texture atlases should be sampled in the same way that `gtexture` is sampled.
15+
- [`uniform sampler2D normals`](current/reference/buffers/atlases/#uniform-sampler2d-normals)
16+
- [`uniform sampler2D specular`](current/reference/buffers/atlases/#uniform-sampler2d-specular)
1917

2018
## Formats
2119
There are two standard formats used for encoding PBR data in the normal and specular maps - oldPBR (also known as seusPBR) and labPBR.
@@ -40,22 +38,22 @@ A texture pack can optionally declare that it is LabPBR compliant (and the versi
4038

4139

4240
If labPBR is declared at all, the following preprocessor define will be declared
43-
```
44-
// texture.properties
41+
```properties
42+
# texture.properties
4543
format=lab-pbr
4644
```
47-
```
45+
```glsl
4846
// this will be defined
4947
MC_TEXTURE_FORMAT_LAB_PBR
5048
```
5149

5250
Additionally, if a version is specified, a further define will be declared. **For example, with version 1.3:**
53-
```
54-
// texture.properties
51+
```properties
52+
# texture.properties
5553
format=lab-pbr/1.3
5654
```
57-
```
58-
// this will be defined
55+
```glsl
56+
// these will be defined
5957
MC_TEXTURE_FORMAT_LAB_PBR
6058
MC_TEXTURE_FORMAT_LAB_PBR_1_3
6159
```
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Texture Atlases
3+
description: Buffers containing textures used to render geometry.
4+
sidebar:
5+
label: Texture Atlases
6+
order: 1
7+
---
8+
9+
The coordinates used to sample the texture atlases in a gbuffers pass are obtained in the vertex shader using the following code:
10+
11+
```glsl title="Compatibility Profile"
12+
coord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
13+
```
14+
```glsl title="Core Profile"
15+
coord = (textureMatrix * vec4(vaUV0, 0.0, 1.0)).xy;
16+
```
17+
18+
For more information, see [`vaUV0`](http://localhost:4321/current/reference/attributes/vauv0/).
19+
20+
Texture atlases are *not bound* in non-gbuffers passes. To access them in other passes, [custom textures](/current/reference/buffers/custom_textures/#texture-types) can be used.
21+
22+
### `uniform sampler2D gtexture`
23+
`gtexture` is the main texture atlas, used to obtain the albedo color of any geometry rendered in a gbuffers pass. It is usually multiplied by the result of [`gl_Color`](/current/reference/attributes/overview/)/[`vaColor`](/current/reference/attributes/vacolor/) (passed through from the vertex shader) to obtain the final color value.
24+
25+
:::caution[Warning]
26+
Some shaderpacks may use other aliases such as `tex`, as samplers using texture names that do not exist will simply bind to the atlas. *This is undefined behavior and should not be relied upon.*
27+
28+
`texture` is a valid alias in `#version 120`, however in any newer version of GLSL this is a reserved keyword and should not be used.
29+
:::
30+
31+
### `uniform sampler2D normals`
32+
`normals` is the normal map atlas. If the resource pack does not have a texture suffixed with `_n` for the current geometry, or there is no resource pack loaded, then the value returned will be as follows.
33+
34+
| Component | Value (0-255) |
35+
|-----------|---------------|
36+
| `r` | 127 |
37+
| `g` | 127 |
38+
| `b` | 255 |
39+
| `a` | 255 |
40+
41+
*Note that the values returned when sampling the texture are in the 0-1 range, whereas they are displayed here in the 0-255 range.*
42+
43+
For information on how to use these values, see [PBR Standards](/current/how-to/pbr_standards/).
44+
45+
### `uniform sampler2D specular`
46+
`specular` is the specular map atlas. If the resource pack does not have a texture suffixed with `_s` for the current geometry, or there is no resource pack loaded, then the value returned will be as follows.
47+
48+
| Component | Value (0-255) |
49+
|-----------|---------------|
50+
| `r` | 0 |
51+
| `g` | 0 |
52+
| `b` | 0 |
53+
| `a` | 0 |
54+
55+
*Note that the values returned when sampling the texture are in the 0-1 range, whereas they are displayed here in the 0-255 range.*
56+
57+
For information on how to use these values, see [PBR Standards](/current/how-to/pbr_standards/).

0 commit comments

Comments
 (0)