Unexpected shader behavior - light cutoff

I’m trying to build a BRDF shader, and I’m starting with something very basic - simply mapping NdotL to the RGB in the lighting function. However, when I do this, materials with the shader show a fullbright area and then an immediate sharp transition to full dark, instead of the smooth gradient one would expect.

Worse, the fullbright area doesn’t always correspond to the position of the light - it seems semi-random. I suspect this to be some kind of Unity bug because if I select an object that causes a GUI overlay to appear in the editor window, then the shader appears as it should for a brief moment, but returns to the broken version as soon as I mouse over the editor window.

Code below, and screenshots of the broken version and the way it looks when I get the editor to display it correctly.

Anyone have any ideas?


Shader "CookbookShaders/BRDF" {
	Properties {
		_EmissiveColor ("Emissive", color) = (1,1,1,1)
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200
		#pragma surface surf Ramp
		#pragma target 3.0

		float4 _EmissiveColor;
		struct Input {
			float2 uv_MainTex;
		half4 LightingRamp(SurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
			float NdotL = dot(s.Normal, lightDir);
			float4 c;
			c.rgb = float3(NdotL,NdotL,NdotL);
			c.a = s.Alpha;
			return c;

		void surf (Input IN, inout SurfaceOutput o) {
			half4 c = _EmissiveColor; //float4(.5,.5,.5,1);//tex2D (_MainTex, IN.uv_MainTex);
			o.Albedo = c.rgb;
			o.Alpha = c.a;
	FallBack "Diffuse"

The shader when malfunctioning:

The shader when I can trick Unity into displaying it correctly for half a second: