Advertisement
Guest User

Toon/lit Emision

a guest
Dec 16th, 2018
86
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.         _MainTex ("Base (RGB)", 2D) = "white" {}
  6.         _Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
  7.         _Illum ("Illumin (A)", 2D) = "white" {}
  8.         _EmissionLM ("Emission (Lightmapper)", Float) = 0
  9.     }
  10.  
  11.     SubShader {
  12.         Tags { "RenderType"="Opaque" }
  13.         LOD 200
  14.        
  15. CGPROGRAM
  16. #pragma surface surf ToonRamp
  17.  
  18. sampler2D _Ramp;
  19.  
  20. // custom lighting function that uses a texture ramp based
  21. // on angle between light direction and normal
  22. #pragma lighting ToonRamp exclude_path:prepass
  23. inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
  24. {
  25.     #ifndef USING_DIRECTIONAL_LIGHT
  26.     lightDir = normalize(lightDir);
  27.     #endif
  28.    
  29.     half d = dot (s.Normal, lightDir)*0.5 + 0.5;
  30.     half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
  31.    
  32.     half4 c;
  33.     c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
  34.     c.a = 1;
  35.     return c;
  36. }
  37.  
  38.  
  39. sampler2D _MainTex;
  40. sampler2D _Illum;
  41. float4 _Color;
  42. float4 _ColorE;
  43.  
  44. struct Input {
  45.     float2 uv_MainTex : TEXCOORD0;
  46.     float2 uv_Illum;
  47. };
  48.  
  49. void surf (Input IN, inout SurfaceOutput o) {
  50.     half4 tex = tex2D(_MainTex, IN.uv_MainTex);
  51.     half4 c = tex * _Color;
  52.     half4 e = tex * _ColorE;
  53.     o.Albedo = c.rgb;
  54.     o.Emission = e.rgb * tex2D(_Illum, IN.uv_Illum).rgb;
  55.     o.Alpha = c.a;
  56. }
  57. ENDCG
  58.  
  59.     }
  60.  
  61.     Fallback "Self-Illumin/VertexLit"
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement