struct VS_OUTPUT
{
    float4 pos  : POSITION;
    float4 diff : COLOR0;
    float2 Txcoord0 : TEXCOORD0;
};

// The world view and projection matrices
float4x4 World;
float4x4 ViewProj;

float4 LightDir0;
float4 LightDir1;

float4 LightColor0;
float4 LightColor1;

float4 AmbientColor;

float4 DiffuseIn;

texture TEXTURE;   


VS_OUTPUT VS(float4 Pos  : POSITION0, float3 Normal : NORMAL0, float2 Txcoord : TEXCOORD0)
{
    VS_OUTPUT Out = (VS_OUTPUT)0;
	
	float4 pos01 = Pos;
	float3 normal = Normal;	
		
	float4 wPos = mul(pos01, World);
	float3 wNormal = mul(normal, World);
	wNormal = normalize(wNormal);				
		
    Out.pos = mul(wPos, ViewProj);
    Out.Txcoord0 = Txcoord;
    
    //Set our color 
    
    // 1st light
    //float diffuse0 = dot(wNormal, LightDir0);  
	//float4 diffuseColor0 = LightColor0*diffuse0;
   
    //float4 diffuseColorSum = diffuseColor0;
	//Out.diff = AmbientColor + DiffuseIn*diffuseColorSum;
	
	// 1st light
	float diffuse0 = max(dot(wNormal, LightDir0), 0);  
	float4 diffuseColor0 = LightColor0*diffuse0;
    
	// 2nd light  
	float diffuse1 = max(dot(wNormal, LightDir1), 0);
	float4 diffuseColor1 = LightColor1*diffuse1;
               
	float4 diffuseColorSum = diffuseColor0 + diffuseColor1;
	Out.diff = AmbientColor + DiffuseIn*diffuseColorSum;	
	Out.diff.a = DiffuseIn.a;
		

    return Out;
}
    

technique T
{
    pass P0
    {
        VertexShader = compile vs_1_1 VS();
        PixelShader  = NULL;

		FillMode = Solid;
        Lighting = False;
        AlphaBlendEnable = True;        
        SrcBlend  = SrcAlpha;
        DestBlend = InvSrcAlpha;
        
        ColorOp[0]   = Modulate;
        ColorArg1[0] = Texture;
        ColorArg2[0] = Diffuse;

        AlphaOp[0]   = Modulate;
        AlphaArg1[0] = Texture;
        AlphaArg2[0] = Diffuse;        
        
        MinFilter[0] = Linear;
        MagFilter[0] = Linear;
        MipFilter[0] = Linear;

        Texture[0]   = <TEXTURE>;
    }
}
