本文共 1132 字,大约阅读时间需要 3 分钟。
Shader "Sbin/TexShader"{ Properties { _MainTex ("Texture", 2D) = "white" {} _U("U",range(-0001,0.001)) = 0 _V("V",range(0,1)) = 0 } SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float _U; float _V; struct v2f{ float4 pos:POSITION; float2 uv:TEXCOORD0; }; v2f vert (appdata_base v) { v2f o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv = v.texcoord.xy; return o; } fixed4 frag (v2f v) : COLOR { fixed4 col = tex2D(_MainTex, v.uv);//第一个参数:纹理,第二个参数UV向量 return col; } ENDCG } }}