Skip to main content
Adding another example effect
Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

Texture coordinates are usually 2-dimensional. But developers can add a third or fourth component to achieve some effects, like sampling from a volume texture, specifying which layer of an array texture to read from, or using projective texturing.

You can author these 3D "UVW" coordinates (or 4D coordinates, though I don't know a common name for the fourth component) in your modelling software, or using the Mesh.SetUVs method, which has overrides for working with Vector3 or Vector4 in addition to the usual Vector2.

The Shader Graph does not know a priori which mesh you will use the shader on, or how many dimensions a given UV channel might have, so it errs on the side of too much and picks the largest option supported by a single vertex attribute. That way if you do something unusual with a third or fourth component, you're not locked out of using that vertex data in the graph.

When Unity compiles this graph down to actual shader code, it may make variants that strip out the unneeded components, since it can follow through the graph to see if they're ever used in an expression. That would be worth experimenting with, as I haven't tested that myself yet.

Texture coordinates are usually 2-dimensional. But developers can add a third or fourth component to achieve some effects, like specifying which layer of an array texture to read from, or using projective texturing.

You can author these 3D "UVW" coordinates (or 4D coordinates, though I don't know a common name for the fourth component) in your modelling software, or using the Mesh.SetUVs method, which has overrides for working with Vector3 or Vector4 in addition to the usual Vector2.

The Shader Graph does not know a priori which mesh you will use the shader on, or how many dimensions a given UV channel might have, so it errs on the side of too much and picks the largest option supported by a single vertex attribute. That way if you do something unusual with a third or fourth component, you're not locked out of using that vertex data in the graph.

When Unity compiles this graph down to actual shader code, it may make variants that strip out the unneeded components, since it can follow through the graph to see if they're ever used in an expression. That would be worth experimenting with, as I haven't tested that myself yet.

Texture coordinates are usually 2-dimensional. But developers can add a third or fourth component to achieve some effects, like sampling from a volume texture, specifying which layer of an array texture to read from, or using projective texturing.

You can author these 3D "UVW" coordinates (or 4D coordinates, though I don't know a common name for the fourth component) in your modelling software, or using the Mesh.SetUVs method, which has overrides for working with Vector3 or Vector4 in addition to the usual Vector2.

The Shader Graph does not know a priori which mesh you will use the shader on, or how many dimensions a given UV channel might have, so it errs on the side of too much and picks the largest option supported by a single vertex attribute. That way if you do something unusual with a third or fourth component, you're not locked out of using that vertex data in the graph.

When Unity compiles this graph down to actual shader code, it may make variants that strip out the unneeded components, since it can follow through the graph to see if they're ever used in an expression. That would be worth experimenting with, as I haven't tested that myself yet.

Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

Texture coordinates are usually 2-dimensional. But developers can add a third or fourth component to achieve some effects, like specifying which layer of an array texture to read from, or using projective texturing.

You can author these 3D "UVW" coordinates (or 4D coordinates, though I don't know a common name for the fourth component) in your modelling software, or using the Mesh.SetUVs method, which has overrides for working with Vector3 or Vector4 in addition to the usual Vector2.

The Shader Graph does not know a priori which mesh you will use the shader on, or how many dimensions a given UV channel might have, so it errs on the side of too much and picks the largest option supported by a single vertex attribute. That way if you do something unusual with a third or fourth component, you're not locked out of using that vertex data in the graph.

When Unity compiles this graph down to actual shader code, it may make variants that strip out the unneeded components, since it can follow through the graph to see if they're ever used in an expression. That would be worth experimenting with, as I haven't tested that myself yet.