Advertisement
Guest User

Untitled

a guest
Jan 9th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Toony Colors Free
  2. // (c) 2012,2016 Jean Moreno
  3.  
  4.  
  5. // Want more features ? Check out Toony Colors Pro+Mobile 2 !
  6. // http://www.jeanmoreno.com/toonycolorspro/
  7.  
  8.  
  9. Shader "Toony Colors Free/Regular"
  10. {
  11.     Properties
  12.     {
  13.         //TOONY COLORS
  14.         _Color ("Color", Color) = (0.5,0.5,0.5,1.0)
  15.         _HColor ("Highlight Color", Color) = (0.6,0.6,0.6,1.0)
  16.         _SColor ("Shadow Color", Color) = (0.3,0.3,0.3,1.0)
  17.        
  18.         //DIFFUSE
  19.         _MainTex ("Main Texture (RGB)", 2D) = "white" {}
  20.        
  21.         //TOONY COLORS RAMP
  22.         _Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
  23.        
  24.     }
  25.    
  26.     SubShader
  27.     {
  28.         Tags { "RenderType"="Opaque" }
  29.        
  30.         CGPROGRAM
  31.        
  32.         #pragma surface surf ToonyColorsCustom
  33.         #pragma target 2.0
  34.         #pragma glsl
  35.        
  36.        
  37.         //================================================================
  38.         // VARIABLES
  39.        
  40.         fixed4 _Color;
  41.         sampler2D _MainTex;
  42.        
  43.        
  44.         struct Input
  45.         {
  46.             half2 uv_MainTex;
  47.         };
  48.        
  49.         //================================================================
  50.         // CUSTOM LIGHTING
  51.        
  52.         //Lighting-related variables
  53.         fixed4 _HColor;
  54.         fixed4 _SColor;
  55.         sampler2D _Ramp;
  56.        
  57.         //Custom SurfaceOutput
  58.         struct SurfaceOutputCustom
  59.         {
  60.             fixed3 Albedo;
  61.             fixed3 Normal;
  62.             fixed3 Emission;
  63.             half Specular;
  64.             fixed Alpha;
  65.         };
  66.        
  67.         inline half4 LightingToonyColorsCustom (SurfaceOutputCustom s, half3 lightDir, half3 viewDir, half atten)
  68.         {
  69.             s.Normal = normalize(s.Normal);
  70.             fixed ndl = max(0, dot(s.Normal, lightDir)*0.5 + 0.5);
  71.            
  72.             fixed3 ramp = tex2D(_Ramp, fixed2(ndl,ndl));
  73.         #if !(POINT) && !(SPOT)
  74.             ramp *= atten;
  75.         #endif
  76.             _SColor = lerp(_HColor, _SColor, _SColor.a);    //Shadows intensity through alpha
  77.             ramp = lerp(_SColor.rgb,_HColor.rgb,ramp);
  78.             fixed4 c;
  79.             c.rgb = s.Albedo * _LightColor0.rgb * ramp;
  80.             c.a = s.Alpha;
  81.         #if (POINT || SPOT)
  82.             c.rgb *= atten;
  83.         #endif
  84.             return c;
  85.         }
  86.        
  87.        
  88.         //================================================================
  89.         // SURFACE FUNCTION
  90.        
  91.         void surf (Input IN, inout SurfaceOutputCustom o)
  92.         {
  93.             fixed4 mainTex = tex2D(_MainTex, IN.uv_MainTex);
  94.            
  95.             o.Albedo = mainTex.rgb * _Color.rgb;
  96.             o.Alpha = mainTex.a * _Color.a;
  97.            
  98.         }
  99.        
  100.         ENDCG
  101.     }
  102.    
  103.     Fallback "Diffuse"
  104.     CustomEditor "TCF_MaterialInspector"
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement