_ObjectSpaceLightPos[0] not working

I try to access _ObjectSpaceLightPos[0] in a CG shader, as it should be defined according to http://docs.unity3d.com/Documentation/Components/SL-BuiltinValues.html. I know lighting should be done through surface shaders, but I want to have only very particular light calculations that only need to work with a single light source.

If I add _ObjectSpaceLightPos[0], I get “undefined variable _ObjectSpaceLightPos”.

What’s the catch?

Shader "Lightingtest" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
}

SubShader { 
	Tags { "RenderType"="Opaque"}
	LOD 400
	
	Pass {
	
		CGPROGRAM
		#pragma vertex vert
		#pragma fragment frag
		#pragma fragmentoption ARB_precision_hint_fastest
		#include "UnityCG.cginc"
		
		
		struct appdata_t {
			float4 vertex : POSITION;
		};
		
		struct v2f {
			float4 vertex : POSITION;
		};
		
		v2f vert (appdata_t v)
		{
			v2f o;
			o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
			return o;
		}
		
		half4 frag( v2f i ) : COLOR
		{
			return _ObjectSpaceLightPos[0];
		}
		ENDCG
	}
}
}

I discovered the arcane by looking at the UnityCG.cginc file.

It seems you can get it using this notation:

ObjSpaceLightDir(v.vertex);

Add the following in the Pass:
Tags { “LightMode” = “Pixel” }