游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1012|回复: 0

Parallel-Split Shadow Maps for many xfiles

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2009-2-4 19:34:00 | 显示全部楼层 |阅读模式
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?


  1. void CPSSM::RenderScene(D3DXMATRIX &mView, D3DXMATRIX &mProj)
  2. {
  3.         // Set constants
  4.         //
  5.         D3DXMATRIX mViewProj=mView * mProj;
  6.        
  7.         _pEffect->SetVector("g_vLightDir",&_vLightDir);
  8.         _pEffect->SetVector("g_vLightColor",&_vLightDiffuse);
  9.         _pEffect->SetVector("g_vAmbient",&_vLightAmbient);
  10.         _pEffect->SetFloat("g_fShadowMapSize",(FLOAT)_iShadowMapSize);

  11.         // enable effect
  12.         unsigned int iPasses=0;
  13.         _pEffect->Begin(&iPasses,0);

  14.         // for each pass in effect
  15.         for(unsigned int i=0;i<iPasses;i++)
  16.         {

  17.                 // start pass
  18.                 _pEffect->BeginPass(i);
  19.                 {

  20.                         std::list<HRObject>::iterator p_object;

  21.                         for (p_object=m_p_object_list->begin();p_object!=m_p_object_list->end();++p_object)
  22.                         {
  23.                                 int nModelID=p_object->GetModelID();
  24.                                 HRMeshAdv* pMesh=(HRMeshAdv*)(*m_p_model_list)[nModelID];

  25.                                 D3DXMATRIX mWorld;
  26.                                 mWorld=CalculateWorldMatrixFromObject(&(*p_object));

  27.                                 _pEffect->SetMatrix("g_mViewProj",&(mWorld*mViewProj));
  28.                                 _pEffect->CommitChanges();

  29.                                 pMesh->RenderPSSM(m_pD3DDevice);
  30.                         }

  31.                         // for each subset in mesh
  32.                         //for(DWORD j=0;j<_iMeshMaterials;j++)
  33.                         //{
  34.                         //        // draw subset
  35.                         //        _pMesh->DrawSubset(j);
  36.                         //}

  37.                 }
  38.                 // end pass
  39.                 _pEffect->EndPass();

  40.         }
  41.         // disable effect
  42.         _pEffect->End();
  43. }
复制代码


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).
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-20 10:18

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表