DepthOnly.shader 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Shader "Hidden/VolumetricFog2/DepthOnly"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _AlphaCutOff("Alpha CutOff", Float) = 0
  7. _Cull("Culling", Int) = 2
  8. }
  9. SubShader
  10. {
  11. ColorMask 0
  12. ZWrite On
  13. Cull [_Cull]
  14. Pass
  15. {
  16. CGPROGRAM
  17. #pragma vertex vert
  18. #pragma fragment frag
  19. #pragma multi_compile_local _ DEPTH_PREPASS_ALPHA_TEST
  20. #include "UnityCG.cginc"
  21. half _AlphaCutOff;
  22. sampler2D _MainTex;
  23. struct appdata
  24. {
  25. float4 vertex : POSITION;
  26. #if DEPTH_PREPASS_ALPHA_TEST
  27. float2 uv : TEXCOORD0;
  28. #endif
  29. };
  30. struct v2f
  31. {
  32. float4 vertex : SV_POSITION;
  33. #if DEPTH_PREPASS_ALPHA_TEST
  34. float2 uv : TEXCOORD0;
  35. #endif
  36. };
  37. v2f vert (appdata v)
  38. {
  39. v2f o;
  40. o.vertex = UnityObjectToClipPos(v.vertex);
  41. #if DEPTH_PREPASS_ALPHA_TEST
  42. o.uv = v.uv;
  43. #endif
  44. return o;
  45. }
  46. half4 frag (v2f i) : SV_Target
  47. {
  48. #if DEPTH_PREPASS_ALPHA_TEST
  49. half4 color = tex2D(_MainTex, i.uv);
  50. clip(color.a - _AlphaCutOff);
  51. #endif
  52. return 0;
  53. }
  54. ENDCG
  55. }
  56. }
  57. }