Jump to content
  • Advertisement
Sign in to follow this  

shadow maps with directional light

This topic is 3672 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The difference of directional light and point light in shadow maps is the light projection,right? I want to modify the shadow maps source code of point light to directional light. But I have a confuse about the projection matrix of directional light in line11. The line11 should be float h=2*NEARPLANE*tanf(0.5f/2.0f);, the angle should be equal to fovY/2. In practice, the angle is not equal to fovY/2. Could somebody tell why? Is the angle is incorrect in calculation. How do calculate the Width of the view plane and the Height of view plane in the function of D3DXMatrixOrthoLH?
HRESULT CreateShadowMap()

	// view and projection matrix for the light source
	D3DXMATRIX mView, mProj;
	D3DXVECTOR3 vLookatPt = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	D3DXVECTOR3 vUpVec    = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	D3DXMatrixLookAtLH(&mView, &m_LightPos, &vLookatPt, &vUpVec);

	float h=2*NEARPLANE*tanf(0.5f*2.0f);
	float w=h;

#define _USE_DIR_LIGHT_
#ifdef _USE_DIR_LIGHT_
	D3DXMatrixOrthoLH(&mProj,w,h,NEARPLANE, FARPLANE);
	D3DXMatrixPerspectiveFovLH(&mProj, 0.5f, 1.0f, NEARPLANE, FARPLANE);

[Edited by - akira32 on November 23, 2008 8:56:32 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!