如果加了alpha就会透,这也是surface shader的不足,但是clip可以解决。。
Shader "Custom/TranDiffExt" {
Properties {_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
//Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
//Tags{"Queue"="Overlay"}
Tags{"Queue"="AlphaTest" "RenderType"="Opaque"}
//LOD 200
//Blend Off
//Blend One Zero
//ZWrite On
//ZTest LEqual
//AlphaTest Greater [_Cutoff]
CGPROGRAM
#pragma surface surf Lambert
#include "UnityCG.cginc"
sampler2D _MainTex;
fixed4 _Color;
float _Cutoff;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
clip(o.Alpha-_Cutoff);
}
ENDCG
}
}