Shader Graph7-texture coordinates (on)

1. The relationship between texture and model

The texture is a picture, which is the picture on the left below. Put this picture on the sphere, and then you will get the globe we usually see. This process is UV mapping, that is, positioning the two-dimensional coordinates of the picture in three-dimensional space , that is, x, y becomes x, y, z.

2. Open Unity to create a new Materila, open Shader Graph, and copy the picture below to Textures as a picture for testing UV.

Here we use the TexCoord node to represent texture coordinates, how to control texture coordinate values ​​through addition, subtraction, multiplication and division. Because the texture coordinates are u and v, which are two channels, our variable should choose Constant2Vector. Then we changed the Preview to a cube for easy observation.

Then we try to modify the value of R to 0.1, and then modify the value of G to 0.1 (R needs to be changed back to 0)

 

We found that the value control of R is the value of texture coordinate U, and the value control of G is the value of texture coordinate V. The larger the U value, the texture image will move to the left, and the larger the V value, the texture image will move up.

 The multiplication parameter becomes 0.5, and the parameter becomes 2. Pay attention to the Constant variable here. We want to operate the values ​​of the two channels of uv at the same time. We found that when the variable is small, the texture is scaled up, and when the variable is large, the texture is scaled down.

We will not look at division and subtraction, because it is the opposite of multiplication and addition.

Finally we add a Time node to animate the texture. Adding a Multiply is to make the texture move slower.

Add another Sine node to move the texture back and forth, because the Sine function is a value range from -1 to 1.

 3. Let's open Unity and take a look, create a new Shader Graph, the first one is Add, the second one is Multiply, the third one is Time, and the fourth one is Sine.

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/zhuziying99/article/details/130012379