Guest User

Untitled

a guest
Aug 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. Shader "Custom/TextureClippingCode"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Main texture", 2D) = "" {}
  6. _ClipValue("Clip value", Range(0.0, 1.0)) = 1.0
  7. }
  8. SubShader
  9. {
  10. Tags { "RenderType"="Opaque" }
  11. LOD 100
  12.  
  13. Pass
  14. {
  15. CGPROGRAM
  16. #pragma vertex vert
  17. #pragma fragment frag
  18.  
  19. #include "UnityCG.cginc"
  20.  
  21. struct appdata
  22. {
  23. float4 vertex : POSITION;
  24. float2 uv : TEXCOORD0;
  25. };
  26.  
  27. struct v2f
  28. {
  29. float2 uv : TEXCOORD0;
  30. float4 vertex : SV_POSITION;
  31. };
  32.  
  33. sampler2D _MainTex;
  34. float4 _MainTex_ST;
  35.  
  36. Float _ClipValue;
  37.  
  38. v2f vert (appdata v)
  39. {
  40. v2f o;
  41. o.vertex = UnityObjectToClipPos(v.vertex);
  42. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  43. return o;
  44. }
  45.  
  46. fixed4 frag (v2f i) : SV_Target
  47. {
  48. if(i.uv.x > _ClipValue)
  49. {
  50. discard;
  51. }
  52. fixed4 mainColor = tex2D(_MainTex, i.uv);
  53. return mainColor;
  54. }
  55. ENDCG
  56. }
  57. }
  58. }
Add Comment
Please, Sign In to add comment