【What is _ maintex_st?]
In Unity's built-in unbind/texture, float4 _ maintex_st is referenced as follows:
// Unlit shader. Simplest possible textured shader.// - no lighting// - no lightmap support// - no per-material colorShader "Unlit/Texture" {Properties { _MainTex ("Base (RGB)", 2D) = "white" {}}SubShader { Tags { "RenderType"="Opaque" } LOD 100 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata_t { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : SV_POSITION; half2 texcoord : TEXCOORD0; }; sampler2D _MainTex; float4 _MainTex_ST; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); return o; } fixed4 frag (v2f i) : SV_Target { fixed4 col = tex2D(_MainTex, i.texcoord); return col; } ENDCG }}}
View code
Transform_tex macro:
Indeed for any texture property, Unity provides value for float4 with "_ ST" suffix. the X, Y contains texture scale, and Z, W contains translation (offset ).
The _ st variable has four values, XY is texture scale, and ZW is offset.
In material, tiling can be set to XY, and offset to ZW.
Reference: http://forum.unity3d.com/threads/what-is-_maintex_st.24962/
What is _ maintex_st?