UnlitAlphaCutout.shader 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Unlit alpha-cutout shader.
  2. // - no lighting
  3. // - no lightmap support
  4. Shader "MTE/Grass/UnlitAlphaCutout"
  5. {
  6. Properties
  7. {
  8. _MainTex("Grass Texture", 2D) = "white" {}
  9. _Cutoff("Alpha cutoff", Range(0,1)) = 0.5
  10. }
  11. SubShader
  12. {
  13. Tags
  14. {
  15. "Queue" = "AlphaTest"
  16. "IgnoreProjector" = "True"
  17. "RenderType" = "TransparentCutout"
  18. }
  19. LOD 100
  20. CULL OFF//no back face culling
  21. Lighting Off
  22. Pass {
  23. CGPROGRAM
  24. #pragma vertex vert
  25. #pragma fragment frag
  26. #pragma target 2.0
  27. #pragma multi_compile_fog
  28. #include "UnityCG.cginc"
  29. struct appdata_t {
  30. float4 vertex : POSITION;
  31. float2 texcoord : TEXCOORD0;
  32. };
  33. struct v2f {
  34. float4 vertex : SV_POSITION;
  35. float2 texcoord : TEXCOORD0;
  36. UNITY_FOG_COORDS(1)
  37. };
  38. sampler2D _MainTex;
  39. float4 _MainTex_ST;
  40. fixed _Cutoff;
  41. v2f vert (appdata_t v)
  42. {
  43. v2f o;
  44. o.vertex = UnityObjectToClipPos(v.vertex);
  45. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  46. UNITY_TRANSFER_FOG(o,o.vertex);
  47. return o;
  48. }
  49. fixed4 frag (v2f i) : SV_Target
  50. {
  51. fixed4 col = tex2D(_MainTex, i.texcoord);
  52. clip(col.a - _Cutoff);
  53. UNITY_APPLY_FOG(i.fogCoord, col);
  54. return col;
  55. }
  56. ENDCG
  57. }
  58. }
  59. }