Changeset 2333 for GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
- Timestamp:
- 04/24/07 14:04:48 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
r2321 r2333 26 26 void OgreDepthShadowMapRenderingRun::createDepthMap() 27 27 { 28 if(light->getType() == Light::LT_POINT) 29 { 30 depthMapTexture = createCubeRenderTexture(name, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White); 31 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 32 blurredDepthMapTexture = createCubeRenderTexture(blurredname, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White); 33 } 34 else 35 { 28 36 29 37 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, … … 46 54 rt->setAutoUpdated(false); 47 55 48 if(OgreIlluminationManager::getSingleton().getBlurShadowMap( ))56 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 49 57 { 50 58 texPtr = Ogre::TextureManager::getSingleton().createManual(blurredname, … … 64 72 rt->setAutoUpdated(false); 65 73 } 74 } 66 75 } 67 76 … … 72 81 if(light->getType() == Light::LT_POINT) 73 82 { 74 updateDepthMap(); 83 //static int currentFace = 0; 84 //updateDepthCubeFace(currentFace); 85 //currentFace = (currentFace+1)%6; 86 87 for(int i = 0; i < 6 ; i++) 88 updateDepthCubeFace(i); 75 89 } 76 90 else … … 82 96 void OgreDepthShadowMapRenderingRun::updateDepthCubeFace(int facenum) 83 97 { 98 Vector3 lightpos = light->getDerivedPosition(); 99 100 RenderTarget* rt = depthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget(); 101 Camera* cam = rt->getViewport(0)->getCamera(); 102 cam->setPosition(lightpos); 103 cam->setFarClipDistance(lightFarPlane); 104 105 setMaterialForVisibles(materialName, cam, false); 106 rt->update(); 107 restoreMaterials(); 108 109 //rt->writeContentsToFile("shadowmap_" + StringConverter::toString(facenum) + ".dds"); 110 111 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 112 { 113 rt = blurredDepthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget(); 114 Material* mat = (Material*) MaterialManager::getSingleton().getByName("GameTools/BlurCubeFace").getPointer(); 115 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(depthMapTexture->getName()); 116 mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("face", facenum); 117 renderFullscreenQuad("GameTools/BlurCubeFace", rt); 118 119 //rt->writeContentsToFile("shadowmap_blurred_" + StringConverter::toString(facenum) + ".dds"); 120 } 121 84 122 } 85 123 … … 93 131 restoreMaterials(); 94 132 95 if(OgreIlluminationManager::getSingleton().getBlurShadowMap( ))133 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 96 134 { 97 135 rt = blurredDepthMapTexture->getBuffer().getPointer()->getRenderTarget(); … … 108 146 const String& OgreDepthShadowMapRenderingRun::getDepthMapTextureName() 109 147 { 110 if(OgreIlluminationManager::getSingleton().getBlurShadowMap( ))148 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 111 149 return blurredname; 112 150 … … 119 157 if(light!= 0) 120 158 { 121 bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM( );122 bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap( );159 bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM(light->getType()); 160 bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap(light->getType()); 123 161 if(light->getType() == Light::LT_DIRECTIONAL) 124 162 { … … 129 167 frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix()); 130 168 131 Vector3 lightpos = light->get ParentSceneNode()->getWorldPosition();132 Vector3 lightdir = light->getD irection();169 Vector3 lightpos = light->getDerivedPosition(); 170 Vector3 lightdir = light->getDerivedDirection(); 133 171 lightdir.normalise(); 134 172 … … 234 272 frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix()); 235 273 236 Vector3 lightpos = light->get ParentSceneNode()->getWorldPosition();237 Vector3 lightdir = light->getD irection();274 Vector3 lightpos = light->getDerivedPosition(); 275 Vector3 lightdir = light->getDerivedDirection(); 238 276 lightdir.normalise(); 239 277 Radian lightangle = light->getSpotlightOuterAngle(); … … 359 397 else//point light 360 398 { 361 /* Vector3 pos = light->getParentNode()->getWorldPosition(); 362 Vector3 dir = -pos; 363 depthMapCamera->setDirection( dir ); 364 depthMapCamera->setPosition(pos); 365 depthMapCamera->setProjectionType(PT_PERSPECTIVE); 366 depthMapCamera->setFOVy(Radian(Degree(140))); 367 depthMapCamera->setNearClipDistance(1); 368 // depthMapCamera->setFarClipDistance(200); 369 370 //OGRE_EXCEPT(0, "NOT implemented for Pointlight", "OgreDepthShadowMapRenderingRun::refreshLight"); 371 */ 372 /*Vector3 pos = light->getParentNode()->getWorldPosition(); 373 Vector3 dir = -pos; 374 depthMapCamera->setDirection( dir ); 375 depthMapCamera->setPosition(pos); 376 depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC); 377 depthMapCamera->*/ 378 399 lightFarPlane = light->getAttenuationRange(); 400 //no other adjustment needed 379 401 } 380 402 } … … 383 405 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix() 384 406 { 385 return depthMapCamera->getViewMatrix(); 407 Camera* cam = depthMapCamera; 408 if(light->getType() == Light::LT_POINT) 409 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera(); 410 411 return cam->getViewMatrix(); 386 412 } 387 413 388 414 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix() 389 415 { 390 return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix(); 416 Camera* cam = depthMapCamera; 417 if(light->getType() == Light::LT_POINT) 418 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera(); 419 420 return cam->getProjectionMatrixWithRSDepth() * cam->getViewMatrix(); 391 421 } 392 422
Note: See TracChangeset
for help on using the changeset viewer.