Imposter_AlphaCutout.shader 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /************************************************************************************
  2. Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  3. Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
  4. https://developer.oculus.com/licenses/oculussdk/
  5. Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
  6. under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  7. ANY KIND, either express or implied. See the License for the specific language governing
  8. permissions and limitations under the License.
  9. ************************************************************************************/
  10. Shader "Hidden/Imposter_AlphaCutout" {
  11. Properties {
  12. _MainTex ("Texture", 2D) = "white" {}
  13. _Cutoff("Alpha cutoff", Range(0,1)) = 0.5
  14. }
  15. SubShader {
  16. Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
  17. LOD 100
  18. Blend One Zero
  19. Pass {
  20. CGPROGRAM
  21. #pragma vertex vert
  22. #pragma fragment frag
  23. #include "UnityCG.cginc"
  24. struct appdata {
  25. float4 vertex : POSITION;
  26. float2 uv : TEXCOORD0;
  27. UNITY_VERTEX_INPUT_INSTANCE_ID
  28. };
  29. struct v2f {
  30. float2 uv : TEXCOORD0;
  31. float4 vertex : SV_POSITION;
  32. UNITY_VERTEX_OUTPUT_STEREO
  33. };
  34. sampler2D _MainTex;
  35. float4 _MainTex_ST;
  36. float _Cutoff;
  37. v2f vert (appdata v) {
  38. v2f o;
  39. UNITY_SETUP_INSTANCE_ID(v);
  40. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  41. o.vertex = UnityObjectToClipPos(v.vertex);
  42. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  43. return o;
  44. }
  45. fixed4 frag(v2f i) : SV_Target{
  46. float4 color = tex2D(_MainTex, i.uv);
  47. clip(color.a - _Cutoff);
  48. return color;
  49. }
  50. ENDCG
  51. }
  52. }
  53. }