Problem with _LightColor0 in unity 4.3.4

I have been learnng about unity shaders but have not got very far as I keep encountering a
undefined variable “_LightColor0” at line 30

To my understanding the Tags {“LightMode” = “ForwardBase”} should provide the _LightColor0 variable.

I am using Unity 4.3.4

Shader "Custom/Test" 
		Tags {"LightMode" = "ForwardBase"} 
			#pragma vertex vert
			#pragma fragment frag
			//base input structs
			struct vertexI
				float4 vertex : POSITION;
				float3 normal : NORMAL;
			struct vertexO
				float4 pos : SV_POSITION;
				float4 col : COLOR;
			//vertex function
			vertexO vert(vertexI v)
				vertexO o;
				o.pos = v.vertex;
				o.col = _LightColor0;
				return o;
			//fragment function
			float4 frag(vertexO i) : COLOR
				return i.col;
	//Commeted out during development
	//FallBack "Diffuse"

But this code throws the undefined error please help I have been trying to solve this for nearly a week :frowning:

_LightColor0 comes from Lighting.cging, add this to your shader:

#include "Lighting.cginc"

Although _LightColor0 comes from pipeline input, you have to declare _LightColor0 as uniform variable.

uniform float4 _LightColor0;

And you have to mux modelview and projection matrix to vertex.

o.pos = mux(UNITY_MATRIX_MVP, v.vertex);

_LightColor0 is not declared (defined) anywhere

put this before your SubShader and see if that fixes anything


 _LightColor0 ("Light Color 0", Color)  = (1.0, 1.0, 1.0, 1.0)