源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
1.5 KiB

пре 1 месец
  1. Shader "SuYou/Lightmap_Cutout" {
  2. Properties {
  3. _Color ("Main Color", Color) = (1,1,1,1)
  4. _MainTex ("Base", 2D) = "white" {}
  5. _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  6. }
  7. CGINCLUDE
  8. half _Cutoff;
  9. sampler2D _MainTex;
  10. ENDCG
  11. SubShader {
  12. Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
  13. Pass {
  14. CGPROGRAM
  15. #include "UnityCG.cginc"
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. #pragma multi_compile_fog
  19. #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
  20. fixed4 _Color;
  21. struct appdata_t {
  22. float4 vertex : POSITION;
  23. float2 texcoord : TEXCOORD0;
  24. float2 texcoord1 : TEXCOORD1;
  25. };
  26. struct v2f
  27. {
  28. half4 pos : SV_POSITION;
  29. half2 uv : TEXCOORD0;
  30. #ifdef LIGHTMAP_ON
  31. half2 uv2 : TEXCOORD1;
  32. #endif
  33. UNITY_FOG_COORDS(2)
  34. };
  35. float4 _MainTex_ST;
  36. v2f vert (appdata_t v)
  37. {
  38. v2f o;
  39. o.pos = UnityObjectToClipPos (v.vertex);
  40. #ifdef LIGHTMAP_ON
  41. o.uv = v.texcoord;
  42. o.uv2 = v.texcoord1 * unity_LightmapST.xy + unity_LightmapST.zw;
  43. #else
  44. o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
  45. #endif
  46. UNITY_TRANSFER_FOG(o,o.pos);
  47. return o;
  48. }
  49. fixed4 frag (v2f i) : COLOR0
  50. {
  51. fixed4 tex = tex2D (_MainTex, i.uv) * _Color;
  52. clip( tex.a - _Cutoff );
  53. #ifdef LIGHTMAP_ON
  54. fixed3 lm = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap,i.uv2));
  55. tex.rgb *= lm;
  56. #endif
  57. UNITY_APPLY_FOG(i.fogCoord, tex);
  58. return tex;
  59. }
  60. ENDCG
  61. }
  62. }
  63. FallBack Off
  64. }