Trying to create a retro-styled vertex lightmapping system here. I have a pretty good idea how to do it, except for one problem: Don't know where to store the lighting information.

Can somebody tell me how exactly the D3DVERTEX struct works? I assumed I could store each vertex's color (along with some other environmental parameter) in the third texture coordinate set. But unless I am trying to read from the wrong coordinates in the shader, it is not behaving the way I had hoped:

Code:
void VS (
in float4 inPos: POSITION,
in float2 inCoord:TEXCOORD0,
in float4 inColor:TEXCOORD2,
out float4 outPos: POSITION,
out float2 outCoord:TEXCOORD0,
out float4 outColor:TEXCOORD1)
{
	outPos = mul( inPos, matWorldViewProj );
	outCoord = inCoord;
	outColor[0] = inColor[0];
}

float4 PS (
in float4 inColor: TEXCOORD1,
in float2 inCoord:TEXCOORD0
) : COLOR0
{
	
	float4 base = tex2D(mapBase,inCoord);
	base *= inColor;
	return base;
}



For testing purposes, I tried assigning every vertex to a medium green color as follows:

Code:
var i;
	for(i = 0; i < ent_vertices(cakes[0]); ++i)
	{
		CONTACT* c = ent_getvertex(cakes[0], NULL, i);
		c.v.x3 = 0;
		c.v.y3 = floatv(0.5);
		c.v.z3 = 0;
		ent_setvertex(cakes[0], c, i);
	}



Instead of the expected effect, the entire model tints bright red (regardless of which coordinate I set to 0.5) with some strange black triangles along the edges of the texture map.

Is there something going on with that texture set that is causing the data to get messed up? Or is there something I'm missing?