Advertisement
dnnkeeper

LevelCutout shader

Feb 10th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. Shader "Custom/LevelCutout" {
  2. Properties {
  3.     _Color ("Main Color", Color) = (1,1,1,1)
  4.     _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
  5.     _BumpMap ("Normalmap", 2D) = "bump" {}
  6.     _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  7.     _CutoffLevel ("cutoff level", Float) = 0.5
  8. }
  9.  
  10. SubShader {
  11.     Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
  12.     LOD 300
  13.    
  14. CGPROGRAM
  15. #pragma surface surf Lambert vertex:vert alphatest:_Cutoff
  16.  
  17. sampler2D _MainTex;
  18. sampler2D _BumpMap;
  19. fixed4 _Color;
  20. fixed _CutoffLevel;
  21.  
  22. struct Input {
  23.     float2 uv_MainTex;
  24.     float2 uv_BumpMap;
  25.     float3 localPos;
  26. };
  27.  
  28. void vert (inout appdata_full v, out Input o) {
  29.    UNITY_INITIALIZE_OUTPUT(Input,o);
  30.    o.localPos = v.vertex.xyz;
  31.  }
  32.  
  33. void surf (Input IN, inout SurfaceOutput o) {
  34.     fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  35.     o.Albedo = c.rgb;
  36.     o.Alpha = (IN.localPos.y < _CutoffLevel)? 0 : c.a;
  37.     o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  38. }
  39. ENDCG
  40. }
  41.  
  42. FallBack "Transparent/Cutout/Diffuse"
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement