TexCliipTwoSiide.shader 1.7 KB

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