You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.0 KiB

  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. SubShader {
  8. Tags { "RenderType"="Opaque" }
  9. LOD 200
  10. CGPROGRAM
  11. #pragma surface surf ToonRamp
  12. sampler2D _Ramp;
  13. // custom lighting function that uses a texture ramp based
  14. // on angle between light direction and normal
  15. #pragma lighting ToonRamp exclude_path:prepass
  16. inline half4 LightingToonRamp (SurfaceOutput s, half3 lightDir, half atten)
  17. {
  18. #ifndef USING_DIRECTIONAL_LIGHT
  19. lightDir = normalize(lightDir);
  20. #endif
  21. half d = dot (s.Normal, lightDir)*0.5 + 0.5;
  22. half3 ramp = tex2D (_Ramp, float2(d,d)).rgb;
  23. half4 c;
  24. c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
  25. c.a = 0;
  26. return c;
  27. }
  28. sampler2D _MainTex;
  29. float4 _Color;
  30. struct Input {
  31. float2 uv_MainTex : TEXCOORD0;
  32. };
  33. void surf (Input IN, inout SurfaceOutput o) {
  34. half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  35. o.Albedo = c.rgb;
  36. o.Alpha = c.a;
  37. }
  38. ENDCG
  39. }
  40. Fallback "Diffuse"
  41. }