Advertisement
Guest User

Untitled

a guest
Dec 25th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/On Off Lighting"
  2. {
  3.         Properties
  4.         {
  5.             _Color ("Color", Color) = (1,1,1,1)
  6.             _Shadow ("Shadow Color", Color) = (1,1,1,1)
  7.             _ShadowStrength ("Shadow Strength", Range(0,1)) = 0.2
  8.         }
  9.         SubShader
  10.         {
  11.             Tags { "RenderType" = "Opaque" }
  12.             CGPROGRAM
  13.             #pragma surface surf OnOff fullforwardshadows
  14.    
  15.             half4 _Color;
  16.             half4 _Shadow;
  17.             half _ShadowStrength;
  18.  
  19.             // just want to know if we're in light or shadow, so simply ON/OFF (thus the SIGN)
  20.             half4 LightingOnOff (SurfaceOutput s, half3 lightDir, half atten)
  21.             {
  22.                 half NdotL = dot (s.Normal, lightDir);
  23.                 return abs(sign(NdotL * atten));
  24.             }
  25.  
  26.             // not used but still here, w/e
  27.             struct Input { float2 uv_MainTex; };
  28.        
  29.             // Want to somehow take the lighting result above, and make the result color be the Color value,
  30.             // shifted towards Shadow value (ex. result = lerp(_Color, _Shadow, LightingResult * _ShadowStrength))
  31.             void surf (Input IN, inout SurfaceOutput o)
  32.             {
  33.                 o.Albedo = _Color.rgb;
  34.                 o.Gloss = 0;
  35.                 o.Specular = 0;
  36.             }
  37.             ENDCG
  38.         }
  39.         Fallback "Diffuse"
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement