float4x4 World: WORLD;
float4x4 View: VIEW;
float4x4 Projection: PROJECTION;

bool UseVertexColor = true;

float4 DiffuseColor = float4(0.5, 0.5, 0.5, 1);

texture DiffuseTexture <string uiname="DiffuseTexture";>;
sampler Samp = sampler_state
{
    Texture   = (DiffuseTexture);
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
};

struct vs2ps
{
	float4 Pos: POSITION;
	float4 Col: COLOR0;
	float4 TexCd: TEXCOORD0;
};

vs2ps VS (float4 P:POSITION, 
	float4 C:COLOR0, 
	float4 TC:TEXCOORD0)
{
	vs2ps Out = (vs2ps)0;
	
	Out.Pos = mul(mul(mul(P, World), View), Projection);
	Out.Col = C;
	Out.TexCd = TC;
	
	return Out;
}

float4 PS(vs2ps In) : COLOR
{
	float4 c = tex2D(Samp, In.TexCd);
	
	if (UseVertexColor) {
		c += In.Col;
		c *= 0.5f;
	}
	
	return c;
}

technique DrawSimple
{
	pass P0
    {
        VertexShader = compile vs_1_1 VS();
        PixelShader = compile ps_1_4 PS();
    }
}