182 lines
4.5 KiB
Plaintext
182 lines
4.5 KiB
Plaintext
|
Shader "Zhanyou/Mobile/Transparent/DiffuseAlphaTest" {
|
|||
|
Properties {
|
|||
|
_MainTex ("Base (RGB)", 2D) = "white" {}
|
|||
|
_Cutoff("Alpha Cutoff", Range(0, 1)) = 0.5
|
|||
|
_Emission ("Emission", Range(0, 1)) = 0
|
|||
|
}
|
|||
|
|
|||
|
SubShader {
|
|||
|
Tags { "Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout" }
|
|||
|
|
|||
|
// Forward Base
|
|||
|
Pass
|
|||
|
{
|
|||
|
Name "FORWARD"
|
|||
|
Tags { "LightMode" = "ForwardBase" }
|
|||
|
|
|||
|
CGPROGRAM
|
|||
|
#define UNITY_PASS_FORWARDBASE
|
|||
|
#include "UnityGiBase.cginc"
|
|||
|
#pragma multi_compile_fwdbase
|
|||
|
#pragma multi_compile_fog
|
|||
|
#pragma vertex vert_Base
|
|||
|
#pragma fragment frag
|
|||
|
#pragma multi_compile __ PLAYER_HALO_ON
|
|||
|
|
|||
|
uniform sampler2D _MainTex;
|
|||
|
uniform float4 _MainTex_ST;
|
|||
|
uniform half _Emission;
|
|||
|
uniform half _Cutoff;
|
|||
|
|
|||
|
fixed4 frag(v2f_Base i) : SV_TARGET
|
|||
|
{
|
|||
|
fixed4 c = tex2D(_MainTex, TRANSFORM_TEX(i.uv, _MainTex));
|
|||
|
clip(c.a - _Cutoff);
|
|||
|
// <20><><EFBFBD>編<EFBFBD><E7B7A8>
|
|||
|
fixed3 worldNormal = fixed3(i.tSpace0.z, i.tSpace1.z, i.tSpace2.z);
|
|||
|
|
|||
|
// <20><>UnityGi<47><69><EFBFBD><EFBFBD>
|
|||
|
GET_UNITY_GI_COLOR;
|
|||
|
|
|||
|
// <20>Է<EFBFBD><D4B7><EFBFBD><E2B9A6>
|
|||
|
c.rgb = giColor + c.rgb * _Emission;
|
|||
|
#if PLAYER_HALO_ON
|
|||
|
c.rgb += _DirectionalLightColor * LightColorFromWorld(worldPos);
|
|||
|
#endif
|
|||
|
UNITY_APPLY_FOG(i.fogCoord, c);
|
|||
|
UNITY_OPAQUE_ALPHA(c.a);
|
|||
|
return c;
|
|||
|
}
|
|||
|
ENDCG
|
|||
|
}
|
|||
|
// Forward Add
|
|||
|
// ע<><D7A2>ʵ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>ͼֻͨ<D6BB><CDA8>metaͨ<61><CDA8>ʵ<EFBFBD>֣<EFBFBD>Forward Add<64><64><EFBFBD><EFBFBD><EFBFBD>ڱ༭<DAB1><E0BCAD><EFBFBD><EFBFBD><DEB9><EFBFBD><EFBFBD><EFBFBD>ͼʱԤ<CAB1><D4A4>
|
|||
|
// <20><EFBFBD><F2B5A5B4><EFBFBD><EFBFBD><EFBFBD>Forward AddҲʹ<D2B2>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD><D5BA><EFBFBD>Ұ<EFBFBD><D2B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD>
|
|||
|
// <20><>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʡȥ<CAA1><C8A5><EFBFBD><EFBFBD><EFBFBD>߹<EFBFBD><DFB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD><CBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷨<EFBFBD><E3B7A8>
|
|||
|
Pass
|
|||
|
{
|
|||
|
Name "FORWARD_ADD"
|
|||
|
Tags { "LightMode" = "ForwardAdd" }
|
|||
|
ZWrite Off
|
|||
|
Blend One One
|
|||
|
CGPROGRAM
|
|||
|
#define UNITY_PASS_FORWARDADD
|
|||
|
#include "UnityGiBase.cginc"
|
|||
|
#pragma multi_compile_fwdadd
|
|||
|
#pragma multi_compile_fog
|
|||
|
#pragma skip_variants INSTANCING_ON
|
|||
|
#pragma vertex vert_Add
|
|||
|
#pragma fragment frag
|
|||
|
uniform sampler2D _MainTex;
|
|||
|
uniform float4 _MainTex_ST;
|
|||
|
uniform half _Cutoff;
|
|||
|
|
|||
|
fixed4 frag(v2f_Add i) : SV_TARGET
|
|||
|
{
|
|||
|
#ifdef LIGHTMAP_ON
|
|||
|
fixed4 c = fixed4(0.0, 0.0, 0.0, 0.0);
|
|||
|
#else
|
|||
|
fixed4 c = tex2D(_MainTex, TRANSFORM_TEX(i.uv, _MainTex));
|
|||
|
half NtoL = max(0.0, i.lightDir.z);
|
|||
|
UNITY_LIGHT_ATTENUATION(atten, i, i.worldPos);
|
|||
|
c.rgb = c.rgb * atten * _LightColor0.rgb * NtoL;
|
|||
|
#endif
|
|||
|
clip(c.a - _Cutoff);
|
|||
|
UNITY_APPLY_FOG(i.fogCoord, c);
|
|||
|
UNITY_OPAQUE_ALPHA(c.a);
|
|||
|
return c;
|
|||
|
}
|
|||
|
ENDCG
|
|||
|
}
|
|||
|
// Shadow Caster
|
|||
|
// ---- shadow caster pass:
|
|||
|
Pass {
|
|||
|
Name "ShadowCaster"
|
|||
|
Tags { "LightMode" = "ShadowCaster" }
|
|||
|
ZWrite On ZTest LEqual
|
|||
|
|
|||
|
CGPROGRAM
|
|||
|
#pragma vertex vert
|
|||
|
#pragma fragment frag
|
|||
|
#pragma multi_compile_shadowcaster
|
|||
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|||
|
#include "HLSLSupport.cginc"
|
|||
|
#include "UnityShaderVariables.cginc"
|
|||
|
#define UNITY_PASS_SHADOWCASTER
|
|||
|
#include "UnityCG.cginc"
|
|||
|
#include "Lighting.cginc"
|
|||
|
half _Cutoff;
|
|||
|
|
|||
|
sampler2D _MainTex;
|
|||
|
float4 _MainTex_ST;
|
|||
|
struct v2f {
|
|||
|
V2F_SHADOW_CASTER;
|
|||
|
float2 uv : TEXCOORD1; // _MainTex
|
|||
|
float3 worldPos : TEXCOORD2;
|
|||
|
};
|
|||
|
v2f vert (appdata_full v) {
|
|||
|
v2f o;
|
|||
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
|||
|
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
|||
|
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
|||
|
fixed3 worldNormal = UnityObjectToWorldNormal(v.normal);
|
|||
|
o.worldPos = worldPos;
|
|||
|
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
|
|||
|
return o;
|
|||
|
}
|
|||
|
fixed4 frag (v2f i) : SV_Target {
|
|||
|
fixed4 c = tex2D(_MainTex, i.uv);
|
|||
|
clip (c.a - _Cutoff);
|
|||
|
SHADOW_CASTER_FRAGMENT(i)
|
|||
|
}
|
|||
|
ENDCG
|
|||
|
}
|
|||
|
// Meta
|
|||
|
Pass
|
|||
|
{
|
|||
|
Name "Meta"
|
|||
|
Tags { "LightMode" = "Meta" }
|
|||
|
Cull Off
|
|||
|
|
|||
|
CGPROGRAM
|
|||
|
#define UNITY_PASS_META
|
|||
|
#include "UnityCG.cginc"
|
|||
|
#include "UnityMetaPass.cginc"
|
|||
|
#pragma vertex vert
|
|||
|
#pragma fragment frag
|
|||
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|||
|
#pragma skip_variants INSTANCING_ON
|
|||
|
|
|||
|
uniform half _Cutoff;
|
|||
|
uniform sampler2D _MainTex;
|
|||
|
uniform float4 _MainTex_ST;
|
|||
|
uniform half _Emission;
|
|||
|
|
|||
|
struct v2f {
|
|||
|
float4 pos : SV_POSITION;
|
|||
|
float2 uv : TEXCOORD0;
|
|||
|
};
|
|||
|
|
|||
|
v2f vert(appdata_full v) {
|
|||
|
v2f o;
|
|||
|
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
|||
|
o.pos = UnityObjectToClipPos(v.vertex);
|
|||
|
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
|||
|
return o;
|
|||
|
}
|
|||
|
|
|||
|
fixed4 frag(v2f i) : SV_TARGET
|
|||
|
{
|
|||
|
fixed4 c = tex2D(_MainTex, i.uv);
|
|||
|
clip(c.a - _Cutoff);
|
|||
|
UnityMetaInput metaIN;
|
|||
|
UNITY_INITIALIZE_OUTPUT(UnityMetaInput, metaIN);
|
|||
|
metaIN.Albedo = c.rgb;
|
|||
|
metaIN.Emission = c.rgb * _Emission;
|
|||
|
return UnityMetaFragment(metaIN);
|
|||
|
}
|
|||
|
ENDCG
|
|||
|
}
|
|||
|
}
|
|||
|
Fallback "Zhanyou/Mobile/DiffuseEmit"
|
|||
|
}
|