|
| 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