# 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.

## 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()
{
D3DXMATRIX mS, mT, mR;

// 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);
#else
D3DXMatrixPerspectiveFovLH(&mProj, 0.5f, 1.0f, NEARPLANE, FARPLANE);
#endif


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

1. 1
2. 2
3. 3
Rutin
20
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633656
• Total Posts
3013186
×