Shader "Test/FragmentLambertAlpha" { Properties { _TintColor("Color", color) = (1,1,1,1) _MainTex("Texture", 2D) = "white" {} _Alpha("Alpha Range", Range(0,1)) = 0.5 [Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("Src Blend", Float) = 1 [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("Dst Blend", Float) = 1 [Enum(Off, 0, On, 1)] _ZWrite("ZWrite", Float) = 0 [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 0 [Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull Mode", Float) = 1 }
SubShader { Tags { "Queue"="Transparent" "RenderType"="Transparent" } Pass { Tags {"LightMode"="ForwardBase"} Blend[_SrcBlend] [_DstBlend] ZWrite[_ZWrite] ZTest[_ZTest] Cull[_Cull]
CGPROGRAM #pragma vertex vert #pragma fragment frag # include "UnityCG.cginc" # include "UnityLightingCommon.cginc"
struct v2f { float2 uv : TEXCOORD0; fixed4 diff : COLOR0; float4 vertex : SV_POSITION; };
v2f vert(appdata_base v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = v.texcoord;
half3 worldNormal = UnityObjectToWorldNormal(v.normal); half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz)); o.diff = nl * _LightColor0; o.diff.rgb += ShadeSH9(half4(worldNormal, 1));
return o; }
sampler2D _MainTex; half _Alpha; fixed4 _TintColor;
fixed4 frag(v2f i) : SV_Target { fixed4 col = tex2D(_MainTex, i.uv) * _TintColor;
col *= i.diff; return fixed4(col.rgb, col.a * _Alpha); }
ENDCG } } }
|