/*
Simple diffuse Shader
*/

#preprocessor HLSL_VS

//ModelView
float4x4 mv;
//ModelViewProjection	
float4x4 mvp;
//ModelViewProjectionInverseTranspose
float4x4 mvit;	

float4x4 m_object;	

float4	mat_diffuse;
float4	mat_specular;
float4	mat_ambient;

struct VS_INPUT
{
	float3 position  : POSITION;
	float3 normal    : NORMAL;
	float2 texcoord0 : TEXCOORD0;
	float2 texcoord1 : TEXCOORD1;
};

struct VS_OUTPUT
{
	float4 hposition : POSITION;
	float4 color0    : COLOR0;
	float2 texcoord0 : TEXCOORD0;
	float2 texcoord1 : TEXCOORD1;
};

VS_OUTPUT main( VS_INPUT IN )
{
	VS_OUTPUT OUT;

	float4 v = float4( IN.position.x,IN.position.y,IN.position.z,1.0f );

    	OUT.hposition = mul( v, mvp );
    	float3 vn = normalize(mul(float4(IN.normal.x,IN.normal.y,IN.normal.z,1.0f),mvit).xyz);
 
    	float col = vn.z;
	//mat_diffuse = float4(1,1,1,1);
    	OUT.color0    = float4(mat_diffuse.xyz*col + mat_ambient.xyz,mat_diffuse.w);
    	
   	OUT.texcoord0 = IN.texcoord0;
   	OUT.texcoord1 = IN.texcoord1;

    	return OUT;
}

#preprocessor commands

#define BW_VERTEX_POSITION 	1
#define BW_VERTEX_NORMAL 	2
#define BW_VERTEX_UV 		4
#define BW_VERTEX_COLOR 	8

// vertex structure
VertexProfileCreate(3);
VertexProfileSet(0,0,3,BW_VERTEX_POSITION,0);
VertexProfileSet(1,12,3,BW_VERTEX_NORMAL,0);
VertexProfileSet(2,24,3,BW_VERTEX_UV,0);

#end