演示
实现方案
1.创建一个shader脚本
2.删掉原来的内容:我们自己写
附上完整的shader代码:
Shader "Custom/ZTestAlways"
{
Properties
{
_Color ("Color Tint",Color) = (1,1,1,1)
_MainTex("Main Tex",2D) = "white"{}
}
SubShader
{
Pass{
ZTest Always
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
fixed4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
struct a2v{
float4 texcoord:TEXCOORD0;
float4 vertex :POSITION;
};
struct v2f{
float4 pos :SV_POSITION;
float2 uv:TEXCOORD2;
};
v2f vert(a2v v){
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord*_MainTex_ST.xy+_MainTex_ST.zw;
return o;
}
float4 frag(v2f i):SV_Target{
fixed3 albedo = tex2D(_MainTex,i.uv).rgb*_Color.rgb;
return fixed4(albedo,1.0);
}
ENDCG
}
}
FallBack "Specular"
}
3创建材质球,选择刚才的shader代码
4.然后附加到你的材质球上就可以看到效果啦