SHARE
TWEET

ToonLitDissolveAppear

a guest Jun 25th, 2018 574 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Toon/Lit Dissolve Appear" {
  2.     Properties {
  3.         _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
  4.         _MainTex ("Base (RGB)", 2D) = "white" {}
  5.         _Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
  6.         _NoiseTex("Dissolve Noise", 2D) = "white"{}
  7.         _NScale ("Noise Scale", Range(0, 10)) = 1
  8.         _DisAmount("Noise Texture Opacity", Range(0.01, 1)) = 0
  9.         _Radius("Radius", Range(0, 20)) = 0
  10.         _DisLineWidth("Line Width", Range(0, 2)) = 0
  11.         _DisLineColor("Line Tint", Color) = (1,1,1,1)          
  12.         [Toggle(ALPHA)] _ALPHA("No Shadows on Transparent", Float) = 0
  13.          
  14.     }
  15.  
  16.         SubShader{
  17.             Tags { "RenderType" = "Transparent" }
  18.             LOD 200
  19.          
  20.            
  21.         Blend SrcAlpha OneMinusSrcAlpha // transparency
  22. CGPROGRAM
  23.  
  24. #pragma shader_feature LIGHTMAP
  25. #pragma surface surf ToonRamp alphatest:_ALPHA addshadow// transparency
  26.  
  27. sampler2D _Ramp;
  28.  
  29. // custom lighting function that uses a texture ramp based
  30. // on angle between light direction and normal
  31. #pragma lighting ToonRamp exclude_path:prepass
  32. inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
  33. {
  34.     #ifndef USING_DIRECTIONAL_LIGHT
  35.     lightDir = normalize(lightDir);
  36.     #endif
  37.    
  38.     half d = dot (s.Normal, lightDir)*0.5 + 0.5;
  39.     half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
  40.    
  41.     half4 c;
  42.     c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
  43.     //c.a = 0; we don't want the alpha
  44.     c.a = s.Alpha; // use the alpha of the surface output
  45.     return c;
  46. }
  47. uniform float3 _Position;
  48. float _Radius;
  49.  
  50. sampler2D _MainTex;
  51. float4 _Color;
  52. sampler2D _NoiseTex;//
  53. float _DisAmount, _NScale;//
  54. float _DisLineWidth;//
  55. float4 _DisLineColor;//
  56.  
  57.  
  58. struct Input {
  59.     float2 uv_MainTex : TEXCOORD0;
  60.     float3 worldPos;// built in value to use the world space position
  61.     float3 worldNormal;
  62.    
  63. };
  64.  
  65. void surf (Input IN, inout SurfaceOutput o) {
  66.     half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  67.  
  68. // triplanar noise
  69.      float3 blendNormal = saturate(pow(IN.worldNormal * 1.4,4));
  70.     half4 nSide1 = tex2D(_NoiseTex, (IN.worldPos.xy + _Time.x) * _NScale);
  71.     half4 nSide2 = tex2D(_NoiseTex, (IN.worldPos.xz + _Time.x) * _NScale);
  72.     half4 nTop = tex2D(_NoiseTex, (IN.worldPos.yz + _Time.x) * _NScale);
  73.  
  74.     float3 noisetexture = nSide1;
  75.     noisetexture = lerp(noisetexture, nTop, blendNormal.x);
  76.     noisetexture = lerp(noisetexture, nSide2, blendNormal.y);
  77.  
  78.     // distance influencer position to world position and sphere radius
  79.     float3 dis = distance(_Position, IN.worldPos);
  80.     float3 sphereR = 1 - saturate(dis / _Radius);
  81.  
  82.     float3 sphereRNoise = noisetexture * sphereR.r;
  83.  
  84.     float3 DissolveLineIn = step(sphereRNoise- _DisLineWidth, _DisAmount);
  85.    
  86.     float3 NoDissolve = float3(1, 1, 1) - DissolveLineIn ;
  87.     c.rgb = (DissolveLineIn * _DisLineColor) + (NoDissolve * c.rgb);
  88.     o.Emission =  (DissolveLineIn * _DisLineColor) * 2;
  89.     c.a = step(_DisAmount, sphereRNoise);
  90.     o.Albedo = c.rgb;
  91.     o.Alpha = c.a;
  92.  
  93.  
  94.  
  95. }
  96. ENDCG
  97.  
  98.     }
  99.  
  100.     Fallback "Diffuse"
  101. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top