Wolfos

Untitled

Oct 16th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. Shader "Toon/Bump" {
  2. Properties {
  3.     _Color ("Main Color", Color) = (1,1,1,1)
  4.     _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
  5.     _BumpMap ("Normalmap", 2D) = "bump" {}
  6.     _Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
  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. sampler2D _MainTex;
  36. sampler2D _BumpMap;
  37. fixed4 _Color;
  38.  
  39. struct Input {
  40.     float2 uv_MainTex : TEXCOORD0;
  41.     float2 uv_BumpMap;
  42. };
  43.  
  44. void surf (Input IN, inout SurfaceOutput o) {
  45.     half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  46.     o.Albedo = c.rgb;
  47.     o.Alpha = c.a;
  48.     o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  49. }
  50. ENDCG
  51. }
  52.  
  53. FallBack "Toon/Lighted"
  54. }
Advertisement
Add Comment
Please, Sign In to add comment