UnlitDoubleSidedShader.shader 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. Shader "Unlit/UnlitDoubleSidedShader"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _Cutoff ("Alpha Cutoff", Range(0,1)) = 0.5
  7. }
  8. SubShader
  9. {
  10. Tags { "RenderType"="TransparentCutout" }
  11. LOD 100
  12. Cull Off
  13. Pass
  14. {
  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. };
  26. struct v2f
  27. {
  28. float2 uv : TEXCOORD0;
  29. UNITY_FOG_COORDS(1)
  30. float4 vertex : SV_POSITION;
  31. };
  32. sampler2D _MainTex;
  33. float4 _MainTex_ST;
  34. float _Cutoff; // Alpha cutoff value
  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. return o;
  42. }
  43. fixed4 frag (v2f i) : SV_Target
  44. {
  45. // sample the texture
  46. fixed4 col = tex2D(_MainTex, i.uv);
  47. clip(col.a - _Cutoff);
  48. // apply fog
  49. UNITY_APPLY_FOG(i.fogCoord, col);
  50. return col;
  51. }
  52. ENDCG
  53. }
  54. }
  55. }