Advertisement
Guest User

ToonLit.shader

a guest
Oct 23rd, 2017
16,680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Shader "Toon/Lit" {
  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. }
  7.  
  8. SubShader {
  9. Tags { "RenderType"="Opaque" }
  10. LOD 200
  11.  
  12. CGPROGRAM
  13. #pragma surface surf ToonRamp
  14.  
  15. sampler2D _Ramp;
  16.  
  17. // custom lighting function that uses a texture ramp based
  18. // on angle between light direction and normal
  19. #pragma lighting ToonRamp exclude_path:prepass
  20. inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
  21. {
  22. #ifndef USING_DIRECTIONAL_LIGHT
  23. lightDir = normalize(lightDir);
  24. #endif
  25.  
  26. half d = dot (s.Normal, lightDir)*0.5 + 0.5;
  27. half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
  28.  
  29. half4 c;
  30. c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
  31. c.a = 0;
  32. return c;
  33. }
  34.  
  35.  
  36. sampler2D _MainTex;
  37. float4 _Color;
  38.  
  39. struct Input {
  40. float2 uv_MainTex : TEXCOORD0;
  41. };
  42.  
  43. void surf (Input IN, inout SurfaceOutput o) {
  44. half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  45. o.Albedo = c.rgb;
  46. o.Alpha = c.a;
  47. }
  48. ENDCG
  49.  
  50. }
  51.  
  52. Fallback "Diffuse"
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement