.png)
.png)
.png)
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
}
}
}
.png)
.png)
.png)
.png)
Cg入门21:Fragment shader - 2D纹理采样
原文:http://blog.csdn.net/aa4790139/article/details/50964774