DepthStencilState depthState
{
DepthEnable = TRUE;
DepthWriteMask = ALL;
DepthFunc = LESS_EQUAL;
};

RasterizerState rsSolid
{
	FillMode = Solid;
	CullMode				= BACK;
	DepthClipEnable		= TRUE;
	AntialiasedLineEnable	= TRUE;
	FrontCounterClockwise = TRUE;
	SlopeScaledDepthBias	= 0.0f;
	DepthBiasClamp		= 0.0f;
	DepthBias				= 0;          
};

matrix lightViewMatrix;
matrix lightProjectionMatrix;

matrix modelMatrix;


struct VS_INPUT
{
    float4 pos : POSITION;
    float4 normal : NORMAL;
    float4 tangent : TANGENT;
    float4 binormal : BINORMAL;
    float2 texCoords : TEXCOORD;
};

struct PS_INPUT
{
    float4 pos : SV_POSITION;
    float4 pos2D : TEXCOORD0; 
};

struct PS_OUTPUT
{
    float depth : SV_Target;   
};


PS_INPUT VS( VS_INPUT input )
{
    PS_INPUT output = (PS_INPUT)0;
    output.pos = mul( input.pos, modelMatrix );
    output.pos = mul( output.pos, lightViewMatrix );
    output.pos = mul( output.pos, lightProjectionMatrix );
    
    output.pos2D = output.pos;
        
    return output;
}

PS_OUTPUT PS( PS_INPUT input) : SV_Target
{
	PS_OUTPUT output;
	
	output.depth = input.pos2D.z;
	
	return output;
}


technique10 Render
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
        SetDepthStencilState( depthState, 0 );
		SetRasterizerState( rsSolid );
    }
}


