float4x4 gWorldXf;
float4x4 gViewXf;
float4x4 gProjectionXf;
float4x4 gWorldITXf;

struct VS_IN
{
    float4 Position : POSITION;
    //float4 TexCoords: TEXCOORD0;
    float3 Normal	: NORMAL;
};

struct VS_OUT
{
    float4 Position : POSITION0;
	float4 Normal	: TEXCOORD0;
	//float4 View		: TEXCOORD1;
	//float2 TexCoords: TEXCOORD2;
};

// ---------------------------------------------------------
VS_OUT VertexShaderFunction( 
	VS_IN IN,
	uniform float4x4 WorldXf,
	uniform float4x4 ViewXf,
	uniform float4x4 ProjectionXf,
	uniform float4x4 WorldITXf )
{
    VS_OUT OUT = ( VS_OUT ) 0;

    float4 worldPosition = mul( IN.Position, WorldXf );
    float4 viewPosition = mul( worldPosition, ViewXf );
    OUT.Position = mul( viewPosition, ProjectionXf );
	OUT.Normal = mul( IN.Normal, WorldITXf );
	//OUT.View = ViewXf[3] - worldPosition;
	//OUT.TexCoords = IN.TexCoords.xy;

    return OUT;
}
// ---------------------------------------------------------
float4 PixelShaderFunction( VS_OUT IN ) : COLOR0
{
	float4 N = normalize( IN.Normal );
	float4 ToLight = normalize( float4( 2, 1, -4, 0 ) );
	float lamb = dot( N, ToLight );
	return float4( lamb.xxx*0.5, 1.0 );
	//return float4( 1, 1, 1, 1.0 );
	//return float4( 0, 0, 0, 1.0 );
}
// ---------------------------------------------------------
technique Technique1
{
    pass p0
    {
        VertexShader = compile vs_2_0 VertexShaderFunction(
			gWorldXf,
			gViewXf,
			gProjectionXf,
			gWorldITXf );
        PixelShader = compile ps_2_0 PixelShaderFunction( );
    }
}
