|
|
I saw the paper of Parallel-Split Shadow Maps for Large-scale Virtual Environments. I think this theory can use in my game (with large-scale scene). And I try to implement the theory to my mapeditor. But I encounter a problem. There is a black block when I close to the object(grandstand) in fore. In the PSSM sample code, there is only a xfile called city.x. But my scene have many objects and those have many instances. If I merge all objects in my scene into a big xfile, this problem of black block will not disppear.Could sombody tell how to resolve this problem?
- void CPSSM::RenderScene(D3DXMATRIX &mView, D3DXMATRIX &mProj)
- {
- // Set constants
- //
- D3DXMATRIX mViewProj=mView * mProj;
-
- _pEffect->SetVector("g_vLightDir",&_vLightDir);
- _pEffect->SetVector("g_vLightColor",&_vLightDiffuse);
- _pEffect->SetVector("g_vAmbient",&_vLightAmbient);
- _pEffect->SetFloat("g_fShadowMapSize",(FLOAT)_iShadowMapSize);
- // enable effect
- unsigned int iPasses=0;
- _pEffect->Begin(&iPasses,0);
- // for each pass in effect
- for(unsigned int i=0;i<iPasses;i++)
- {
- // start pass
- _pEffect->BeginPass(i);
- {
- std::list<HRObject>::iterator p_object;
- for (p_object=m_p_object_list->begin();p_object!=m_p_object_list->end();++p_object)
- {
- int nModelID=p_object->GetModelID();
- HRMeshAdv* pMesh=(HRMeshAdv*)(*m_p_model_list)[nModelID];
- D3DXMATRIX mWorld;
- mWorld=CalculateWorldMatrixFromObject(&(*p_object));
- _pEffect->SetMatrix("g_mViewProj",&(mWorld*mViewProj));
- _pEffect->CommitChanges();
- pMesh->RenderPSSM(m_pD3DDevice);
- }
- // for each subset in mesh
- //for(DWORD j=0;j<_iMeshMaterials;j++)
- //{
- // // draw subset
- // _pMesh->DrawSubset(j);
- //}
- }
- // end pass
- _pEffect->EndPass();
- }
- // disable effect
- _pEffect->End();
- }
复制代码
pssm_near_error.jpg is the picture with error when camera closes to the object(grandstand). The error is the big black block.
pssm_normal.jpg is the picture when camera leaves the object(grandstand). |
|