What is _ maintex_st?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.