SHARE
TWEET

ToonLitDisappearMultiple

a guest Jun 25th, 2018 297 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Toon/Lit Dissolve Appear Fog" {
  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.         [Toggle(ALPHA)] _ALPHA("No Shadows on Transparent", Float) = 0
  11.          
  12.     }
  13.  
  14.         SubShader{
  15.             Tags { "RenderType" = "Transparent" }
  16.             LOD 200
  17.             Cull Off
  18.          
  19.            
  20.         Blend SrcAlpha OneMinusSrcAlpha // transparency
  21. CGPROGRAM
  22.  
  23.  
  24.  
  25. #pragma shader_feature LIGHTMAP
  26. #pragma surface surf ToonRamp alphatest:_ALPHA addshadow// transparency
  27.  
  28. sampler2D _Ramp;
  29.  
  30. // custom lighting function that uses a texture ramp based
  31. // on angle between light direction and normal
  32. #pragma lighting ToonRamp exclude_path:prepass
  33. inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
  34. {
  35.     #ifndef USING_DIRECTIONAL_LIGHT
  36.     lightDir = normalize(lightDir);
  37.     #endif
  38.    
  39.     half d = dot (s.Normal, lightDir)*0.5 + 0.5;
  40.     half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
  41.    
  42.     half4 c;
  43.     c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
  44.     //c.a = 0; we don't want the alpha
  45.     c.a = s.Alpha; // use the alpha of the surface output
  46.     return c;
  47. }
  48. uniform float3 _Position;
  49. uniform float _ArrayLength;
  50. uniform float3 _Positions[100];
  51. float _Radius;
  52.  
  53. sampler2D _MainTex;
  54. float4 _Color;
  55. sampler2D _NoiseTex;//
  56. float _DisAmount, _NScale;//
  57.  
  58.  
  59. struct Input {
  60.     float2 uv_MainTex : TEXCOORD0;
  61.     float3 worldPos;// built in value to use the world space position
  62.     float3 worldNormal;
  63.    
  64. };
  65.  
  66. void surf (Input IN, inout SurfaceOutput o) {
  67.     half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  68.  
  69. // triplanar noise
  70.      float3 blendNormal = saturate(pow(IN.worldNormal * 1.4,4));
  71.     half4 nSide1 = tex2D(_NoiseTex, (IN.worldPos.xy + _Time.x) * _NScale);
  72.     half4 nSide2 = tex2D(_NoiseTex, (IN.worldPos.xz + _Time.x) * _NScale);
  73.     half4 nTop = tex2D(_NoiseTex, (IN.worldPos.yz + _Time.x) * _NScale);
  74.  
  75.     float3 noisetexture = nSide1;
  76.     noisetexture = lerp(noisetexture, nTop, blendNormal.x);
  77.     noisetexture = lerp(noisetexture, nSide2, blendNormal.y);
  78.  
  79.     // distance influencer position to world position and sphere radius
  80.     float3 sphereRNoise;
  81.     for  (int i = 0; i < 100; i++){
  82.         float3 dis =  distance(_Positions[i], IN.worldPos);
  83.         float3 sphereR = 1-  saturate(dis / _Radius);
  84.         sphereR *= noisetexture;
  85.         sphereRNoise += (sphereR);
  86.     }
  87.    
  88.     c.a = step(sphereRNoise, _DisAmount);
  89.     o.Albedo = noisetexture + _Color;
  90.     o.Alpha = c.a;
  91.  
  92.  
  93.  
  94. }
  95. ENDCG
  96.  
  97.     }
  98.  
  99.     Fallback "Diffuse"
  100. }
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