- Timestamp:
- 04/24/07 14:04:48 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns
- Files:
-
- 4 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 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp
r2321 r2333 238 238 else 239 239 { 240 Vector3 pos = light->get ParentSceneNode()->getPosition();240 Vector3 pos = light->getDerivedPosition(); 241 241 Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - pos; 242 242 dir.normalise(); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp
r2321 r2333 4 4 #include "OgreDepthShadowMapRenderingRun.h" 5 5 6 Texture* OgrePMWeightComputeRenderingRun::weightTexture = 0; 7 Texture* OgrePMWeightComputeRenderingRun::allWeightsTexture = 0; 8 6 9 OgrePMWeightComputeRenderingRun::OgrePMWeightComputeRenderingRun(String name, String LightName) 7 10 : OgreRenderingRun(1, 1) … … 19 22 void OgrePMWeightComputeRenderingRun::createWeightMap() 20 23 { 21 22 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 23 int width = entryPointCnt / 4096; 24 int height = 4096; 25 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL", 26 "default", 27 TEX_TYPE_2D, 28 width, 29 height, 30 0, 31 0, 32 PF_FLOAT32_R, 33 TU_RENDERTARGET); 34 allWeightsTexture = texPtr.getPointer(); 35 //add viewport to rendertarget 36 HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer(); 37 RenderTarget* rt = hpb->getRenderTarget(); 38 Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA"); 39 Viewport* v = rt->addViewport(wc); 40 v->setOverlaysEnabled(false); 41 rt->setAutoUpdated(false); 42 43 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 44 width = clustercount; 45 height = 1; 46 texPtr = Ogre::TextureManager::getSingleton().createManual(name, 47 "default", 48 TEX_TYPE_2D, 49 width, 50 height, 51 0, 52 0, 53 PF_FLOAT32_R, 54 TU_RENDERTARGET); 55 weightTexture = texPtr.getPointer(); 56 //add viewport to rendertarget 57 hpb = (weightTexture->getBuffer()).getPointer(); 58 rt = hpb->getRenderTarget(); 59 wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 60 v = rt->addViewport(wc); 61 v->setOverlaysEnabled(false); 62 rt->setAutoUpdated(false); 24 if(allWeightsTexture == 0) 25 { 26 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 27 int width = entryPointCnt / 4096; 28 int height = 4096; 29 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL", 30 "default", 31 TEX_TYPE_2D, 32 width, 33 height, 34 0, 35 0, 36 PF_FLOAT16_RGBA, 37 TU_RENDERTARGET); 38 allWeightsTexture = texPtr.getPointer(); 39 //add viewport to rendertarget 40 HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer(); 41 RenderTarget* rt = hpb->getRenderTarget(); 42 Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA"); 43 Viewport* v = rt->addViewport(wc); 44 v->setBackgroundColour(ColourValue::Black); 45 v->setClearEveryFrame(false); 46 v->setOverlaysEnabled(false); 47 rt->setAutoUpdated(false); 48 49 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 50 width = clustercount; 51 height = 1; 52 texPtr = Ogre::TextureManager::getSingleton().createManual(name, 53 "default", 54 TEX_TYPE_2D, 55 width, 56 height, 57 0, 58 0, 59 PF_FLOAT16_RGBA, 60 TU_RENDERTARGET); 61 weightTexture = texPtr.getPointer(); 62 //add viewport to rendertarget 63 hpb = (weightTexture->getBuffer()).getPointer(); 64 rt = hpb->getRenderTarget(); 65 wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 66 v = rt->addViewport(wc); 67 v->setOverlaysEnabled(false); 68 rt->setAutoUpdated(false); 69 } 63 70 } 64 71 … … 83 90 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 84 91 85 Vector3 lightPos = light->get Position();86 Vector3 lightDir = light->getD irection();87 //Radian lightAngle = light->getSpotlightOuterAngle();92 Vector3 lightPos = light->getDerivedPosition(); 93 Vector3 lightDir = light->getDerivedDirection(); 94 Radian lightAngle = light->getSpotlightOuterAngle(); 88 95 89 96 Fparams->setNamedConstant("nRadionColumns", col); … … 91 98 Fparams->setNamedConstant("lightDir", lightDir); 92 99 Fparams->setNamedConstant("lightPower", light->getPowerScale()); 100 Fparams->setNamedConstant("lightColor", light->getDiffuseColour()); 93 101 Fparams->setNamedConstant("lightViewProj", SMrun->getLightViewProjMatrix()); 94 102 Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane()); 103 Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(), 104 light->getAttenuationConstant(), 105 light->getAttenuationLinear(), 106 light->getAttenuationQuadric())); 107 Fparams->setNamedConstant("lightAngleCos", Math::Cos(lightAngle.valueRadians()/2.0)); 108 Fparams->setNamedConstant("spotLightFalloff", light->getSpotlightFalloff()); 95 109 96 110 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( … … 100 114 101 115 RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 102 renderFullscreenQuad(mat->getName(), rt); 116 if(frameNum != rt->getLastFrameNumber()) 117 rt->getViewport(0)->setClearEveryFrame(true); 118 else 119 rt->getViewport(0)->setClearEveryFrame(false); 120 121 renderFullscreenQuad(mat->getName(), rt); 122 103 123 104 124 // rt->writeContentsToFile("allweights.bmp"); 105 125 // rt->writeContentsToFile("allweights.dds"); 106 107 /* float* allweights = new float[entryPointCnt / 4096 * 4096]; 108 PixelBox lockBox(entryPointCnt / 4096, 4096, 1, PF_FLOAT32_R, allweights); 109 allWeightsTexture->getBuffer()->blitToMemory(lockBox); 110 111 ///////////////////DEBUG 112 static BillboardSet* entryPointBBSet = 0; 113 if(entryPointBBSet == 0) 114 { 115 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 116 entryPointBBSet = sm->createBillboardSet("PATHMAP_ENTRYPOINTS", entryPointCnt); 117 entryPointBBSet->setBillboardType(BBT_POINT); 118 entryPointBBSet->setBillboardsInWorldSpace(true); 119 entryPointBBSet->setPointRenderingEnabled(true); 120 for(unsigned int i = 0; i < entryPointCnt; i++) 121 { 122 PathMapEntryPoint EP = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().at(i); 123 Vector3 billboardPosition = EP.position; 124 125 float uCoord = allweights[i]; 126 float vCoord = 0; 127 //float uCoord = ((float) (i % col) + 0.5f) / (float) col; 128 //float vCoord = ((float)(i / col) + 0.5f) / 4096.0f; 129 entryPointBBSet->createBillboard(billboardPosition, ColourValue(uCoord, vCoord, 0, 0)); 130 } 131 entryPointBBSet->setMaterialName("GTP/PM/EPBillboards"); 132 MaterialPtr mater = MaterialManager::getSingleton().getByName("GTP/PM/EPBillboards"); 133 mater->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(allWeightsTexture->getName()); 134 sm->getRootSceneNode()->createChildSceneNode()->attachObject(entryPointBBSet); 135 } 136 137 delete[] allweights;*/ 138 139 ///////////////// 126 140 127 } 141 else 128 else if(light->getType() == Light::LT_POINT) 142 129 { 143 ///not implemented 130 OgreIlluminationManager::getSingleton().createPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP); 131 OgreIlluminationManager::getSingleton().updatePerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP, frameNum); 132 OgreDepthShadowMapRenderingRun* SMrun = (OgreDepthShadowMapRenderingRun*) OgreIlluminationManager::getSingleton() 133 .getPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP)->asOgreRenderingRun(); 134 135 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_ComputeWeights_Point"); 136 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 137 138 Vector3 lightPos = light->getDerivedPosition(); 139 140 Fparams->setNamedConstant("nRadionColumns", col); 141 Fparams->setNamedConstant("lightPos", lightPos); 142 Fparams->setNamedConstant("lightPower", light->getPowerScale()); 143 Fparams->setNamedConstant("lightColor", light->getDiffuseColour()); 144 Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane()); 145 Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(), 146 light->getAttenuationConstant(), 147 light->getAttenuationLinear(), 148 light->getAttenuationQuadric())); 149 150 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( 151 PMEPrun->getEntryPointTextureName()); 152 mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( 153 SMrun->getDepthMapTextureName()); 154 155 RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 156 if(frameNum != rt->getLastFrameNumber()) 157 rt->getViewport(0)->setClearEveryFrame(true); 158 else 159 rt->getViewport(0)->setClearEveryFrame(false); 160 161 renderFullscreenQuad(mat->getName(), rt); 162 144 163 } 145 164 165 } 166 167 void OgrePMWeightComputeRenderingRun::sumWeights(unsigned long frameNum) 168 { 169 RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget(); 170 if(frameNum == rt->getLastFrameNumber())return; 171 172 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 173 int col = entryPointCnt / 4096; 146 174 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 147 175 OgrePMEntryPointMapRenderingRun* PMEPrun = (OgrePMEntryPointMapRenderingRun*) 176 OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_PM_ENTRYPOINTMAP)->asOgreRenderingRun(); 177 148 178 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_SumWeights"); 149 179 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); … … 157 187 allWeightsTexture->getName()); 158 188 159 RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget();160 189 renderFullscreenQuad(mat->getName(), rt); 161 162 //rt->writeContentsToFile("weights.bmp");163 //rt->writeContentsToFile("weights.dds");164 /*165 float* weights = new float[clustercount];166 PixelBox lockBox(clustercount, 1, 1, PF_FLOAT32_R, weights);167 weightTexture->getBuffer()->blitToMemory(lockBox);168 169 delete[] weights;*/170 190 } 171 191 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp
r2321 r2333 100 100 if(light->getType() == Light::LT_DIRECTIONAL) 101 101 { 102 Vector3 dir = light->getD irection();102 Vector3 dir = light->getDerivedDirection(); 103 103 photonMapCamera->setDirection( dir ); 104 104 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius(); … … 113 113 else 114 114 { 115 Vector3 pos = light->get ParentSceneNode()->getPosition();115 Vector3 pos = light->getDerivedPosition(); 116 116 Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - pos; 117 117 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius();
Note: See TracChangeset
for help on using the changeset viewer.