RayTarget.shader 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. Shader "Unlit/RayTarget"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _AlphaCutOff ("CutOff", FLOAT) = 0.5
  7. }
  8. SubShader
  9. {
  10. Pass
  11. {
  12. Tags
  13. {
  14. "Queue" = "Transparent"
  15. "RenderType" = "Transparent"
  16. }
  17. ZWrite Off
  18. Cull Off
  19. ColorMask RGBA
  20. Blend SrcAlpha OneMinusSrcAlpha
  21. CGPROGRAM
  22. #pragma vertex vert
  23. #pragma fragment frag
  24. #include "UnityCG.cginc"
  25. struct appdata
  26. {
  27. float4 vertex : POSITION;
  28. float2 uv : TEXCOORD0;
  29. };
  30. struct v2f
  31. {
  32. float2 uv : TEXCOORD0;
  33. float4 vertex : SV_POSITION;
  34. };
  35. sampler2D _MainTex;
  36. float4 _MainTex_ST;
  37. v2f vert (appdata v)
  38. {
  39. v2f o;
  40. o.vertex = UnityObjectToClipPos(v.vertex);
  41. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  42. return o;
  43. }
  44. fixed4 frag (v2f i) : SV_Target
  45. {
  46. // sample the texture
  47. fixed4 col = tex2D(_MainTex, i.uv);
  48. return col;
  49. }
  50. ENDCG
  51. }
  52. Pass
  53. {
  54. Tags
  55. {
  56. "Queue" = "Opaque"
  57. "RenderType" = "Opaque"
  58. }
  59. ZWrite On
  60. Cull Off
  61. ColorMask 0
  62. Blend Off
  63. CGPROGRAM
  64. #pragma vertex vert
  65. #pragma fragment frag
  66. #include "UnityCG.cginc"
  67. struct appdata
  68. {
  69. float4 vertex : POSITION;
  70. float2 uv : TEXCOORD0;
  71. };
  72. struct v2f
  73. {
  74. float2 uv : TEXCOORD0;
  75. float4 vertex : SV_POSITION;
  76. };
  77. sampler2D _MainTex;
  78. float4 _MainTex_ST;
  79. float _AlphaCutOff;
  80. v2f vert(appdata v)
  81. {
  82. v2f o;
  83. o.vertex = UnityObjectToClipPos(v.vertex);
  84. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  85. return o;
  86. }
  87. fixed4 frag(v2f i) : SV_Target
  88. {
  89. // sample the texture
  90. fixed4 col = tex2D(_MainTex, i.uv);
  91. if (col.w < _AlphaCutOff)
  92. {
  93. discard;
  94. }
  95. return col;
  96. }
  97. ENDCG
  98. }
  99. }
  100. }