资源:
最终效果
代码:
Shader "Custom/TextureID" {
Properties{
_MainTex("Base (RGB)", 2D) = "white" {}
}
SubShader{
Tags { "RenderType" = "Opaque" }
LOD 300
Pass {
Tags { "LightMode" = "Vertex" }
Cull Back
Lighting On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler _MainTex;
float4 _MainTex_ST;
struct a2v {
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 texcoord : TEXCOORD0;
};
struct v2f {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
v2f vert(a2v v) {
v2f o; o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
float4 frag(v2f i) : COLOR {
float2 tc = i.uv;
tc.x = tc.x - floor(tc.x);
tc.y = tc.y - floor(tc.y);
tc.x = tc.x * 0.35;
tc.y = 0.65 + tc.y * 0.35;
fixed4 c = tex2D(_MainTex, tc);
return c;
}
ENDCG
}
}
FallBack "Diffuse"
}
图片导入设置 Wrap->clamp: