//--- Additional Automatic Parameters
float4 colEmi : EMISSIVE;
float4 colDif : DIFFUSE;

texture tex : TEXTURE;

float4 colEdge   : SPECULAR;
float  Thickness : POWER;

//--- Standard Automatic Parameters
float4x4 Wvp : WORLDVIEWPROJECTION;

//--- Manual Parameters
float3 lightPos <string type="entity3d";>;

//--- Vertex Shader Output Structure
struct EdgeVSOut
{
	float4 Pos : POSITION;
	float4 Col : COLOR;
};

//--- Vertex Shader Function
EdgeVSOut EdgeVS
	(
		float3 Pos  : POSITION,
		float3 Norm : NORMAL
	)
{
	EdgeVSOut vsOut;
	float3 p = Pos + Norm * Thickness * 0.002f;
	vsOut.Pos = mul( float4(p,1) , Wvp );
	vsOut.Col = colEdge;
	return vsOut;
}

technique tech
{
	pass p
	{
		//--- Material States
		MaterialEmissive = <colEmi>;
		MaterialDiffuse = <colDif>;
		
		Texture[0] = <tex>;
		
		//--- Light States
		LightEnable[0] = true;
		LightAttenuation0[0] = 1;
		LightDiffuse[0] = {1, 1, 1, 0};
		LightRange[0] = 1000;
		LightPosition[0] = <lightPos>;
		LightType[0] = POINT;
	}
	pass edge
	{
		Texture[0] = NULL;
		LightEnable[0] = false;
		CullMode = CW;
		
		VertexShader = compile vs_1_1 EdgeVS();
	}
}
