Advertisement
Guest User

Untitled

a guest
Feb 7th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/Opacue"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Base (RGB)", 2D) = "white" {}
  6.         _Threshold("Cutout threshold", Range(0,1)) = 0.1
  7.         _Softness("Cutout softness", Range(0,0.5)) = 0.0
  8.     }
  9.     SubShader
  10.     {
  11.         Tags { "RenderType"="Transparent" "Queue" = "Transparent" }
  12.         LOD 100
  13.  
  14.         ZWrite Off
  15.         Blend SrcAlpha OneMinusSrcAlpha
  16.  
  17.         Pass
  18.         {
  19.             CGPROGRAM
  20.             #pragma vertex vert
  21.             #pragma fragment frag
  22.  
  23.             #include "UnityCG.cginc"
  24.  
  25.             struct appdata
  26.             {
  27.                 float4 vertex : POSITION;
  28.                 float2 uv : TEXCOORD0;
  29.             };
  30.  
  31.             struct v2f
  32.             {
  33.                 float2 uv : TEXCOORD0;
  34.                 float4 vertex : SV_POSITION;
  35.             };
  36.  
  37.             sampler2D _MainTex;
  38.             float4 _MainTex_ST;
  39.             float _Threshold;
  40.             float _Softness;
  41.  
  42.             v2f vert(appdata v)
  43.             {
  44.                 v2f o;
  45.                 o.vertex = UnityObjectToClipPos(v.vertex);
  46.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  47.                 return o;
  48.             }
  49.  
  50.             fixed4 frag(v2f i) : SV_Target
  51.             {
  52.                 // sample the texture
  53.                 fixed4 col = tex2D(_MainTex, i.uv);
  54.                 col.a = smoothstep(_Threshold, _Threshold + _Softness,
  55.                     0.333 * (col.r + col.g + col.b));
  56.                 return col;
  57.             }
  58.             ENDCG
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement