AlphaTest_Diffuse.shader 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // Upgrade NOTE: commented out 'float4 unity_LightmapST', a built-in variable
  2. // Upgrade NOTE: commented out 'sampler2D unity_Lightmap', a built-in variable
  3. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
  4. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  5. // Upgrade NOTE: replaced tex2D unity_Lightmap with UNITY_SAMPLE_TEX2D
  6. Shader "Scene/Light_VertexLit/AlphaTest_Diffuse" {
  7. Properties {
  8. _Color ("Main Color", Color) = (1,1,1,1)
  9. _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
  10. _AlphaTex ("千万不要填,系统用的", 2D) = "white" {}
  11. _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  12. }
  13. SubShader {
  14. Tags {"Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="Opaque"}
  15. LOD 200
  16. AlphaTest Off
  17. Pass{
  18. Tags { LightMode = Vertex }
  19. CGPROGRAM
  20. #pragma vertex vert
  21. #pragma fragment frag
  22. #pragma multi_compile _DUMMY _FOG_OF_WAR_ON _FOG_OF_WAR_ON_LOW
  23. #pragma multi_compile _DUMMY _SEPERATE_ALPHA_TEX_ON
  24. #include "UnityCG.cginc"
  25. struct v2f {
  26. float4 pos : SV_POSITION;
  27. float2 uv0 : TEXCOORD0;
  28. float2 uvLM : TEXCOORD1;
  29. };
  30. struct appdata_lightmap {
  31. float4 vertex : POSITION;
  32. float2 texcoord : TEXCOORD0;
  33. float2 texcoord1 : TEXCOORD1;
  34. };
  35. sampler2D _MainTex;
  36. float4 _MainTex_ST;
  37. fixed4 _Color;
  38. fixed _Cutoff;
  39. v2f vert(appdata_lightmap i) {
  40. v2f o;
  41. o.pos = UnityObjectToClipPos(i.vertex);
  42. o.uv0 = TRANSFORM_TEX(i.texcoord, _MainTex);
  43. o.uvLM = i.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  44. return o;
  45. }
  46. fixed4 frag(v2f i) : COLOR {
  47. fixed4 color = tex2D(_MainTex, i.uv0) * _Color;
  48. clip(color.a - _Cutoff);
  49. color.rgb *= DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uvLM));
  50. return color;
  51. }
  52. ENDCG
  53. }
  54. Pass{
  55. Tags { LightMode = VertexLM }
  56. CGPROGRAM
  57. #pragma vertex vert
  58. #pragma fragment frag
  59. #pragma multi_compile _DUMMY _FOG_OF_WAR_ON _FOG_OF_WAR_ON_LOW
  60. #pragma multi_compile _DUMMY _SEPERATE_ALPHA_TEX_ON
  61. #include "UnityCG.cginc"
  62. struct v2f {
  63. float4 pos : SV_POSITION;
  64. float2 uv0 : TEXCOORD0;
  65. float2 uvLM : TEXCOORD1;
  66. };
  67. struct appdata_lightmap {
  68. float4 vertex : POSITION;
  69. float2 texcoord : TEXCOORD0;
  70. float2 texcoord1 : TEXCOORD1;
  71. };
  72. sampler2D _MainTex;
  73. float4 _MainTex_ST;
  74. fixed4 _Color;
  75. fixed _Cutoff;
  76. v2f vert(appdata_lightmap i) {
  77. v2f o;
  78. o.pos = UnityObjectToClipPos(i.vertex);
  79. o.uv0 = TRANSFORM_TEX(i.texcoord, _MainTex);
  80. o.uvLM = i.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  81. return o;
  82. }
  83. fixed4 frag(v2f i) : COLOR {
  84. fixed4 color = tex2D(_MainTex, i.uv0) * _Color;
  85. clip(color.a - _Cutoff);
  86. color.rgb *= DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uvLM));
  87. return color;
  88. }
  89. ENDCG
  90. }
  91. Pass{
  92. Tags { LightMode = VertexLMRGBM }
  93. CGPROGRAM
  94. #pragma vertex vert
  95. #pragma fragment frag
  96. #pragma multi_compile _DUMMY _FOG_OF_WAR_ON _FOG_OF_WAR_ON_LOW
  97. #pragma multi_compile _DUMMY _SEPERATE_ALPHA_TEX_ON
  98. #include "UnityCG.cginc"
  99. struct v2f {
  100. float4 pos : SV_POSITION;
  101. float2 uv0 : TEXCOORD0;
  102. float2 uvLM : TEXCOORD1;
  103. };
  104. struct appdata_lightmap {
  105. float4 vertex : POSITION;
  106. float2 texcoord : TEXCOORD0;
  107. float2 texcoord1 : TEXCOORD1;
  108. };
  109. sampler2D _MainTex;
  110. float4 _MainTex_ST;
  111. fixed4 _Color;
  112. fixed _Cutoff;
  113. v2f vert(appdata_lightmap i) {
  114. v2f o;
  115. o.pos = UnityObjectToClipPos(i.vertex);
  116. o.uv0 = TRANSFORM_TEX(i.texcoord, _MainTex);
  117. o.uvLM = i.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  118. return o;
  119. }
  120. fixed4 frag(v2f i) : COLOR {
  121. fixed4 color = tex2D(_MainTex, i.uv0) * _Color;
  122. clip(color.a - _Cutoff);
  123. color.rgb *= DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uvLM));
  124. return color;
  125. }
  126. ENDCG
  127. }
  128. }
  129. ////FallBack "Transparent/Cutout/VertexLit"
  130. }