Advertisement
OhiraKyou

Ramp Cutoff Transparent

Apr 14th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Cutoff/Ramp Cutoff Transparent" {
  2.  
  3.     Properties {
  4.         _MainTex ("Main Texture", 2D) = "white" {}
  5.         [HDR] _Color ("Main Color", Color) = (0, 0, 0, 1)
  6.         [HDR] _DarkEmissiveColor ("Dark Color", Color) = (0, 0, 0, 1)
  7.         [HDR] _LightEmissiveColor ("Light Color", Color) = (1, 1, 1, 1)
  8.         _Cutoff ("Cutoff", Range (0, 1)) = 0.5
  9.          _Transparency("Transparency", Range(0.0,1.0)) = 0
  10.     }
  11.  
  12.     SubShader {
  13.         Tags {"Queue"="Transparent" "RenderType"="Transparent"}
  14.         CGPROGRAM
  15.         #pragma surface surf Lambert alpha
  16.  
  17.         struct Input {
  18.             float2 uv_MainTex;
  19.             float3 viewDir;
  20.         };
  21.  
  22.         sampler2D _MainTex;
  23.         sampler2D _BumpMap;
  24.         float4 _Color;
  25.         float4 _Transparency;
  26.         float4 _DarkEmissiveColor;
  27.         float4 _LightEmissiveColor;
  28.         float _Cutoff;
  29.  
  30.         void surf (Input IN, inout SurfaceOutput o) {
  31.             o.Albedo = _Color;
  32.             float rampValue = tex2D (_MainTex, IN.uv_MainTex).r;
  33.             float cutoff = step(_Cutoff, rampValue);
  34.             o.Emission = lerp(_DarkEmissiveColor, _LightEmissiveColor, cutoff);
  35.             o.Alpha = lerp(_DarkEmissiveColor.a, _LightEmissiveColor.a, cutoff);
  36.         }
  37.  
  38.         ENDCG
  39.     }
  40.  
  41.     Fallback "Diffuse"
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement