//Vertex Shader
struct vertex
{
float4 position	:	POSITION;
float3 normal	:	NORMAL;
float4 color0	:	COLOR0;
float2 texcoord0	:	TEXCOORD0;
//float depin	:	DEPTH;
};

struct fragment
{
float4 position	:	POSITION;
float3 oNormal	:	TEXCOORD1;
float4 color0	:	COLOR0;
float2 texcoord0	:	TEXCOORD0;
float3 objectPos	:	TEXCOORD2;
float2 texcoord3	:	TEXCOORD3;
float4 objectPos2	:	TEXCOORD4;
float3 Light2color	:	TEXCOORD5;
//float depout	:	DEPTH;
};

// This binding semantic requires CG_PROFILE_ARBVP1 or higher.
uniform float4x4 modelViewProj : state.matrix.mvp;

fragment main( 
			//uniform float	testnum,
			  vertex IN,
			  uniform float4x4 ShadowMapmvmatrix,
			  uniform float4x4 ShadowMapprojmatrix,
			  uniform float4x4 ShadowMapMVPmatrix,
			  uniform float4 MissleLightDirection,
			  uniform float3 paraLightColor
			  )
{
	fragment OUT;
	float4 objectPosShadowMap=mul( ShadowMapMVPmatrix, IN.position );
	OUT.texcoord3.x=objectPosShadowMap.x/(objectPosShadowMap.w*2.0)+0.5;
	OUT.texcoord3.y=objectPosShadowMap.y/(objectPosShadowMap.w*2.0)+0.5;
	OUT.objectPos2 = objectPosShadowMap;

	
	OUT.position = mul( modelViewProj, IN.position );
	OUT.color0 = IN.color0;
	OUT.texcoord0 = IN.texcoord0;
	OUT.oNormal = IN.normal;
	OUT.objectPos = IN.position.xyz;
	

    float3 P = IN.position.xyz;
    float3 N = normalize(IN.normal);
	float3 L = normalize(MissleLightDirection.xyz-P);
	float DotNaL=dot(N, L);
    float diffuseLight = max(DotNaL, 0.0);
    float3 diffuse = paraLightColor * diffuseLight*10.0;

	OUT.Light2color = diffuse;


	return OUT;
}