Skip to content

Commit

Permalink
Merge pull request #321 from Luracasmus/main
Browse files Browse the repository at this point in the history
fix: uniforms: `textureMatrix` improvements
  • Loading branch information
ninjamike1211 authored Aug 23, 2024
2 parents 570260b + 53ebe55 commit 33a9a6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/content/docs/reference/Attributes/vaUV0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ import { Aside } from '@astrojs/starlight/components';

The vertex texture coordinate attribute, equivalent to `gl_MultiTexCoord0` from the compatibility profile.

Usually the coordinate in `vaUV0` corresponds directly to the atlas texture coordinate, however some geometry (such as enchantment glint) requires the texture matrix. Therefore it is always recommended to use [`textureMatrix`](/reference/uniforms/matrices/texturematrix) (or `gl_TextureMatrix[0]` in the compatibility profile).
Usually the coordinate in `vaUV0` corresponds directly to the atlas texture coordinate, however some geometry (such as enchantment glint) requires a texture matrix. Therefore it is always recommended to use [`textureMatrix`](/reference/uniforms/matrices/texturematrix) (or `gl_TextureMatrix[0]` in the compatibility profile) in [gbuffers-style](/reference/programs/overview/#program-order) programs.
```glsl
vec2 coord = (textureMatrix * vec4(vaUV0, 0.0, 1.0)).xy;
```
Equivalent to `gl_TextureMatrix[0]` in the compatibility profile and older GLSL versions.
```glsl
vec2 coord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Aside } from '@astrojs/starlight/components';

### `uniform mat4 textureMatrix;`

Transforms texture coordinates. Used by [`gbuffers_armor_glint`](/reference/programs/gbuffers) to scroll the texture over time.
Transforms texture coordinates. Mainly used in [`gbuffers_armor_glint`](/reference/programs/gbuffers) to scroll the texture over time, but may be applied to other geometry as well (especially by mods). It is therefore strongly recommended to use this matrix in all [gbuffers-style](/reference/programs/overview/#program-order) programs utilizing [`vaUV0`](/reference/attributes/vauv0/).
```glsl
vec2 coord = (textureMatrix * vec4(vaUV0, 0.0, 1.0)).xy;
```
Expand Down

0 comments on commit 33a9a6b

Please sign in to comment.