What does this error mean?

Cg: error C6014: Required output ‘POSITION’ not written at line 0

What does that mean?

Here’s the shader (inspired by yoggy’s recent AO work :slight_smile: )

Shader "Ambient_Occlusion" {
	Properties
	{
		_AmbientOcclusion("Ambient Occlusion", Vector) = (1,1,1,1)
	}
	SubShader
	{
		Pass
		{
			Cull back
			Colormask rgba
			
			CGPROGRAM		
			#pragma vertex vert
			#pragma fragment frag
			#pragma fragmentoption ARB_fog_exp2
			#include "UnityCG.cginc"
			
			struct VertIn
			{
			     float4 pos : POSITION;
			     float4 color : COLOR0;
			};
			
			struct v2f
			{ 
				float4 color : COLOR0;
				float ambient_occlusion_term;
			};
			
			uniform float4 _AmbientOcclusion;
			
			v2f vert( VertIn v )
			{
				v2f o;
				o.ambient_occlusion_term = _AmbientOcclusion.w;
				o.color = v.color;
				return o;
			}
			
			float4 frag( v2f i ) : COLOR
			{
				float4 vAmbient = float4( 0.9, 0.9, 0.9, 1.0 );
				vAmbient.xyz *= i.ambient_occlusion_term;
				return vAmbient; 
			}
			
			ENDCG
		}
	} 
}

In the vertex shader (‘vert’ function) you never output the position of the vertex (v2f structure does not even have a member for it). Without vertex position, the graphics card would not know where to render the polygon.

Thank Aras, that fixed that error.

Now I’m getting two new errors: One saying that none of the subshaders can run on my graphics card (GMA 950) and the other says “source == kShaderChannelNone”

I don’t see why this shader doesn’t work. It’s relatively simple, (compiles down to about 3 different instructions, a MUL , MOV, and PARAM.

Here’s the updated shader:

Shader "Ambient_Occlusion" {
	Properties
	{
		_AmbientOcclusion("Ambient Occlusion", Vector) = (1,1,1,1)
	}
	SubShader
	{
		Pass
		{
			Cull back
			Colormask rgba
			
			CGPROGRAM		
			#pragma vertex vert
			#pragma fragment frag
			#include "UnityCG.cginc"
			
			struct VertIn
			{
			     float4 position : POSITION;
			     float4 color : COLOR0;
			};
			
			struct v2f
			{ 
				float4 position : POSITION;
				float4 color : COLOR0;
				float ambient_occlusion_term;
			};
			
			uniform float4 _AmbientOcclusion;
			
			v2f vert( VertIn v )
			{
				v2f o;
				o.ambient_occlusion_term = _AmbientOcclusion.w;
				o.color = v.color;
				o.position = v.position;
				return o;
			}
			
			float4 frag( v2f i ) : COLOR
			{
				float4 vAmbient = float4( 0.9, 0.9, 0.9, 1.0 );
				vAmbient.xyz *= i.ambient_occlusion_term;
				return vAmbient; 
			}
			
			ENDCG
		}
	} 
}

Position in the vertex input structure has to be named “vertex” in Unity. So change it to:

struct VertIn
{ 
    float4 vertex : POSITION; 
    float4 color : COLOR0; 
};

Yes, the error message is not the best one, will improve that.