Advertisement
NautisShadrick

ToonShading lit outline glow

Dec 16th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Toon/Self-Illumin Lighted" {
  2.     Properties {
  3.         _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
  4.         _ColorE ("Main Emision", Color) = (0.5,0.5,0.5,1)
  5.         _OutlineColor ("Outline Color", Color) = (0,0,0,1)
  6.         _Outline ("Outline width", Range (.002, 0.03)) = .005
  7.         _MainTex ("Base (RGB)", 2D) = "white" {}
  8.         _Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
  9.         _Illum ("Illumin (A)", 2D) = "white" {}
  10.         _EmissionLM ("Emission (Lightmapper)", Float) = 0
  11.     }
  12.  
  13.     SubShader {
  14.         Tags { "RenderType"="Opaque" }
  15.         UsePass "Toon/Basic Outline/OUTLINE"
  16.         LOD 200
  17.        
  18. CGPROGRAM
  19. #pragma surface surf ToonRamp
  20.  
  21. sampler2D _Ramp;
  22.  
  23. // custom lighting function that uses a texture ramp based
  24. // on angle between light direction and normal
  25. #pragma lighting ToonRamp exclude_path:prepass
  26. inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
  27. {
  28.     #ifndef USING_DIRECTIONAL_LIGHT
  29.     lightDir = normalize(lightDir);
  30.     #endif
  31.    
  32.     half d = dot (s.Normal, lightDir)*0.5 + 0.5;
  33.     half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
  34.    
  35.     half4 c;
  36.     c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
  37.     c.a = 1;
  38.     return c;
  39. }
  40.  
  41.  
  42. sampler2D _MainTex;
  43. sampler2D _Illum;
  44. float4 _Color;
  45. float4 _ColorE;
  46.  
  47. struct Input {
  48.     float2 uv_MainTex : TEXCOORD0;
  49.     float2 uv_Illum;
  50. };
  51.  
  52. void surf (Input IN, inout SurfaceOutput o) {
  53.     half4 tex = tex2D(_MainTex, IN.uv_MainTex);
  54.     half4 c = tex * _Color;
  55.     half4 e = tex * _ColorE;
  56.     o.Albedo = c.rgb;
  57.     o.Emission = e.rgb * tex2D(_Illum, IN.uv_Illum).rgb;
  58.     o.Alpha = c.a;
  59. }
  60. ENDCG
  61.  
  62.     }
  63.  
  64.     Fallback "Self-Illumin/VertexLit"
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement