TexCliip.shader 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Shader "Unlit/TexCliip"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. }
  7. SubShader
  8. {
  9. Tags {"Queue" ="Transparent" "RenderType"="Transparent" }
  10. LOD 100
  11. Pass
  12. {
  13. Blend SrcAlpha OneMinusSrcAlpha
  14. CGPROGRAM
  15. #pragma vertex vert
  16. #pragma fragment frag
  17. // make fog work
  18. #pragma multi_compile_fog
  19. #include "UnityCG.cginc"
  20. struct appdata
  21. {
  22. float4 vertex : POSITION;
  23. float2 uv : TEXCOORD0;
  24. float4 color: COLOR;
  25. };
  26. struct v2f
  27. {
  28. float2 uv : TEXCOORD0;
  29. UNITY_FOG_COORDS(1)
  30. float4 vertex : SV_POSITION;
  31. fixed4 color : TEXCOORD2;
  32. };
  33. sampler2D _MainTex;
  34. float4 _MainTex_ST;
  35. v2f vert (appdata v)
  36. {
  37. v2f o;
  38. o.vertex = UnityObjectToClipPos(v.vertex);
  39. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  40. UNITY_TRANSFER_FOG(o,o.vertex);
  41. o.color = v.color;
  42. return o;
  43. }
  44. fixed4 frag (v2f i) : SV_Target
  45. {
  46. // sample the texture
  47. fixed4 col = tex2D(_MainTex, i.uv);
  48. clip(col.a - 0.5);
  49. // apply fog
  50. UNITY_APPLY_FOG(i.fogCoord, col);
  51. col.a = i.color.a;
  52. return col;
  53. }
  54. ENDCG
  55. }
  56. }
  57. }