reprinted from the Wind Yu Chong Unity3d Tutorial College
We will add some answers to these questions in succession.
Q:(1) What does Transform_tex do? (2) float4 _maintex_st in the _maintex_st variable is not used, why do you want to declare it? Answer:(1) In simple terms, the main role of Transform_tex is to take the vertex UV and material ball tiling and offset for the operation, to ensure that the material ball in the scaling and offset settings are correct. (V.texcoord is the vertex UV)
The following two functions are equivalent.
O.UV = Transform_tex (V.texcoord,_maintex);
O.UV = v.texcoord.xy * _maintex_st.xy + _maintex_st.zw;
(2) and _maintex_st St is supposed to be samplertexture meaning, that is, the declaration _maintex is a sampling map, that is, the UV operation. If there is no such sentence, it is not possible to perform transform_tex operations. _maintex_st.xy is the offset in the TILING,ZW. if tiling and offset you leave the default value, that is, tiling () offset to (0,0), you can notO.uv = Transform_tex (V.texcoord,_maintex);change to O.uv = V.texcoord.xy, which can be displayed normally, equivalent to tiling to (0,0) offset, but the tiling value and the value of offset are not working.
Unity3d Tutorial Shader: Special FAQ