Directional Light を複数置いて Culling Mask で制御するのが面倒な時などに
Unlit Shader でも 光の向きを指定したい場合があります。
法線との内積の処理で指定したXYZを利用しているだけで特に特殊な処理はしていません
Shader
Shader "Custom/Unlit/DirectionLight" { Properties { _MainTex ("Texture", 2D) = "white" {} _LightX ("LightDirectionX", float) = 0.0 _LightY ("LightDirectionY", float) = 0.0 _LightZ ("LightDirectionZ", float) = 0.0 _ShadeColor("ShadeColor", Color) = (0.0, 0.0, 0.0) } SubShader { Tags { "RenderType"="Opaque" } Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" half3 _LightDirection; struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; float3 normal : NORMAL; }; struct v2f { float4 vertex : SV_POSITION; float2 uv : TEXCOORD0; float3 normal : NORMAL; }; fixed4 _ShadeColor; sampler2D _MainTex; float4 _MainTex_ST; half _LightX; half _LightY; half _LightZ; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); o.normal = v.normal; return o; } fixed4 frag (v2f i) : SV_Target { half NdotL = dot(i.normal, float3(_LightX, _LightY, _LightZ)); return fixed4(lerp(_ShadeColor, tex2D(_MainTex, i.uv).rgb, max(0, NdotL)), 1); } ENDCG } } }