Changeset 865 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Timestamp:
- 04/30/06 15:31:04 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityOctreeSceneManager.h
r863 r865 9 9 10 10 #include "OgreOctreeHierarchyInterface.h" 11 #include "OgrePlatformQueryManager.h" 11 12 #include "VisibilityManager.h" 12 13 … … 67 68 */ 68 69 bool validatePassForRendering(Pass* pass); 69 70 /** This function renders renderables using false color ids. 71 */ 70 72 void RenderItemBuffer(RenderPriorityGroup* pGroup); 73 /** Renders a single object using false color id. 74 */ 71 75 void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass); 76 /** Overritten from scene manager to include the false color id rendering of the 77 scene objects. 78 */ 72 79 void renderQueueGroupObjects(RenderQueueGroup* pGroup); 73 80 74 81 /** Override from SceneManager so that sub entities can be assigned an id for item buffer. 75 82 */ 76 //Entity* createEntity(const String& entityName, const String& meshName);83 Entity* createEntity(const String& entityName, const String& meshName); 77 84 78 85 /** Returns pointer to visibility manager. … … 85 92 86 93 void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup); 94 /** Override this because we must handle shadows differently. 95 */ 87 96 void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup); 88 97 … … 122 131 bool mRenderNodesContentForViz; 123 132 124 /// render transparents after the hierarchical traversal133 /// if we render transparents after the hierarchical traversal 125 134 bool mDelayRenderTransparents; 126 135 127 /// use a depth pass (i.e., fill only the depth buffer in the first pass)136 /// if we use a depth pass (i.e., fill only the depth buffer in the first pass) 128 137 bool mUseDepthPass; 129 /// flag indicating if we currently renderthe depth pass138 /// if we currently rendering the depth pass 130 139 bool mIsDepthPassPhase; 131 140 … … 155 164 156 165 bool mIsHierarchicalCulling; 166 167 std::ofstream mDummyLog; 157 168 }; 158 169 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityTerrainSceneManager.h
r726 r865 11 11 #include "OgrePlatformQueryManager.h" 12 12 #include "VisibilityManager.h" 13 13 14 14 15 namespace Ogre { … … 55 56 virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 56 57 bool doLightIteration, const LightList* manualLightList = 0); 58 57 59 /** Writes out stats into the Ogre log file. 58 60 */ 59 61 void WriteLog(); 60 62 61 /** We override this because we want to includethe z-fail pass.63 /** Override pass so we can do the z-fail pass. 62 64 */ 63 65 Pass* setPass(Pass* pass); 66 64 67 /** Override from SceneManager so we can skip all but first pass for depth pass. 65 68 */ … … 114 117 void InitVisibilityCulling(Camera *cam); 115 118 119 120 116 121 /// the interface to the scene hierarchy. 117 122 OctreeHierarchyInterface *mHierarchyInterface; … … 156 161 int mLeavePassesInQueue; 157 162 163 158 164 /// if transparent object are considered for item buffer visibility 159 165 bool mRenderTransparentsForItemBuffer; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r863 r865 752 752 mLeavePassesInQueue); 753 753 754 std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;755 LogManager::getSingleton().logMessage(d.str());756 754 } 757 755 //----------------------------------------------------------------------- -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp
r726 r865 11 11 #include <OgreConfigFile.h> 12 12 13 // normal terrain rendering 14 const static NORMAL_RENDER_HACK = false; 15 13 16 namespace Ogre { 14 17 15 18 //----------------------------------------------------------------------- 16 19 VisibilityOctreeSceneManager::VisibilityOctreeSceneManager( 17 GtpVisibility::VisibilityManager *visManager) 18 : 20 GtpVisibility::VisibilityManager *visManager): 21 OctreeSceneManager(), 19 22 mVisibilityManager(visManager), 20 23 mShowVisualization(false), … … 37 40 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 38 41 39 //mDisplayNodes = true; 40 //mShowBoundingBoxes = true; 41 //mShowBoxes = true; 42 if (0) 43 { 44 mDisplayNodes = true; 45 mShowBoundingBoxes = true; 46 mShowBoxes = true; 47 } 42 48 43 49 // TODO: set maxdepth to reasonable value … … 112 118 // ignore 113 119 } 120 // add bounding boxes of rendered objects 114 121 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 115 122 { 116 123 getRenderQueue()->addRenderable(*it); 117 124 } 125 118 126 if (mRenderNodesForViz || mRenderNodesContentForViz) 119 127 { 120 // change node material so it is better suited for visualization128 // HACK: change node material so it is better suited for visualization 121 129 MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 122 130 nodeMat->setAmbient(1, 1, 0); … … 128 136 if (mRenderNodesForViz) 129 137 { 130 if (((*it)->numAttachedObjects() > 0) && ((*it)->numChildren() == 0) 131 && (*it)->getAttachedObject(0)->getMovableType() == "Entity") 138 // render the leaf nodes 139 if (((*it)->numAttachedObjects() > 0) && ((*it)->numChildren() == 0) && 140 (*it)->getAttachedObject(0)->getMovableType() == "Entity") 141 { 132 142 getRenderQueue()->addRenderable((*it)); 143 } 133 144 134 145 // addbounding boxes instead of node itself … … 145 156 Pass *VisibilityOctreeSceneManager::setPass(Pass* pass) 146 157 { 158 if (NORMAL_RENDER_HACK) 159 { 160 return SceneManager::setPass(pass); 161 } 162 163 // TODO: setting vertex program is not efficient 164 //Pass *usedPass = ((mIsDepthPassPhase && !pass->hasVertexProgram()) ? mDepthPass : pass); 165 147 166 // set depth fill pass if we currently do not make an aabb occlusion query 148 Pass *usedPass = (mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery() ? 149 mDepthPass : pass); 167 const bool useDepthPass = 168 (mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery()); 169 170 Pass *usedPass = useDepthPass ? mDepthPass : pass; 150 171 151 172 IlluminationRenderStage savedStage = mIlluminationStage; … … 158 179 } 159 180 160 //-- set vertex program of current pass in order to set correct depth 161 if (mIsDepthPassPhase && mExecuteVertexProgramForAllPasses && pass->hasVertexProgram()) 181 // --- set vertex program of current pass in order to set correct depth 182 if (mExecuteVertexProgramForAllPasses && 183 mIsDepthPassPhase && 184 pass->hasVertexProgram()) 162 185 { 163 186 // add vertex program of current pass to depth pass … … 174 197 } 175 198 } 176 else if (mDepthPass->hasVertexProgram()) 199 else if (mDepthPass->hasVertexProgram()) // reset vertex program 177 200 { 178 201 mDepthPass->setVertexProgram(""); 179 202 } 180 203 181 // s tore depth write flag to reset later182 bool IsDepthWrite = usedPass->getDepthWriteEnabled();204 // save old depth write: needed for item buffer 205 const bool IsDepthWrite = usedPass->getDepthWriteEnabled(); 183 206 184 207 // global option which enables / disables depth writes … … 187 210 usedPass->setDepthWriteEnabled(false); 188 211 } 189 //else if (mIsItemBufferPass) {usedPass = mItemBufferPass;} 190 212 213 214 //-- set actual pass here 191 215 Pass *result = SceneManager::setPass(usedPass); 216 192 217 193 218 // reset depth write … … 205 230 void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 206 231 { 232 if (NORMAL_RENDER_HACK) 233 { 234 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 235 return; 236 } 237 207 238 //-- show visible scene nodes and octree bounding boxes from last frame 208 239 if (mShowVisualization) … … 223 254 } 224 255 // only shadow casters will be rendered in shadow texture pass 225 //mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);256 if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 226 257 } 227 258 … … 234 265 void VisibilityOctreeSceneManager::_renderVisibleObjects() 235 266 { 236 237 //InitVisibilityCulling(mCameraInProgress); 238 //mVisibilityManager->ApplyVisibilityCulling(); 239 240 if(1){ 267 if (NORMAL_RENDER_HACK) 268 { 269 OctreeSceneManager::_renderVisibleObjects(); 270 271 return; 272 } 273 241 274 InitDepthPass(); // create material for depth pass 242 275 InitItemBufferPass(); // create material for item buffer pass … … 266 299 else //-- the hierarchical culling algorithm 267 300 { 301 // this is also called in TerrainSceneManager: really 302 // nexessary? 303 mDestRenderSystem -> setLightingEnabled(false); 304 268 305 // don't render backgrounds for item buffer 269 306 if (mUseItemBuffer) … … 284 321 285 322 OctreeSceneManager::_renderVisibleObjects(); 286 323 ///////////////////////////////////////////////// 287 324 288 325 #ifdef GTP_VISIBILITY_MODIFIED_OGRE … … 297 334 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 298 335 336 // exclude this queues from hierarchical rendering 337 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 299 338 300 339 // set all necessary parameters for … … 311 350 mVisibilityManager->ApplyVisibilityCulling(); 312 351 313 // delete remaining renderables from queue (all not in mLeavePassesInQueue) 352 // delete remaining renderables from queue: 353 // all which are not in mLeavePassesInQueue) 314 354 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 315 355 _deleteRenderedQueueGroups(mLeavePassesInQueue); … … 324 364 mLeavePassesInQueue = 0; 325 365 366 #if 1 326 367 // add visible nodes found by the visibility culling algorithm 327 368 if (mUseDepthPass) 328 369 { 329 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 370 NodeList::const_iterator it, it_end = mVisible.end(); 371 372 //getRenderQueue()->clear(); 373 for (it = mVisible.begin(); it != it_end; ++ it) 330 374 { 331 375 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 332 376 } 333 377 } 334 335 //-- werender all remaining queue objects336 // used for depth pass, transparents, overlay378 #endif 379 //-- now we can render all remaining queue objects 380 //-- used for depth pass, transparents, overlay 337 381 clearSpecialCaseRenderQueues(); 382 338 383 OctreeSceneManager::_renderVisibleObjects(); 339 384 340 } 385 } // hierarchical culling 341 386 342 387 // reset ambient light 343 388 setAmbientLight(savedAmbient); 344 } 389 345 390 getRenderQueue()->clear(); // finally clear render queue 346 OGRE_DELETE(mRenderQueue); // HACK: should be cleared before...347 //WriteLog(); // write out stats 348 391 if (0) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 392 393 if (0) WriteLog(); // write out stats 349 394 } 350 395 … … 352 397 void VisibilityOctreeSceneManager::_updateSceneGraph(Camera* cam) 353 398 { 399 if (NORMAL_RENDER_HACK) 400 { 401 OctreeSceneManager::_updateSceneGraph(cam); 402 return; 403 } 404 354 405 mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); 355 406 mHierarchyInterface->SetRenderSystem(mDestRenderSystem); … … 431 482 return true; 432 483 } 484 433 485 if (key == "UseArbQueries") 434 486 { … … 491 543 << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", " 492 544 << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetTestGeometryForVisibleLeaves()) << ", " 493 << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << " \n"545 << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 494 546 << "Hierarchy nodes: " << mNumOctants << ", " 495 547 << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", " … … 497 549 << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", " 498 550 << "Frustum culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumFrustumCulledNodes() << ", " 499 << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << "\n"; 500 /*<< "avg. FPS: " << mCurrentViewport->getTarget()->getAverageFPS() << ", " 501 << "best FPS: " << mCurrentViewport->getTarget()->getBestFPS() << ", " 502 << "worst FPS: " << mCurrentViewport->getTarget()->getWorstFPS() << ", " 503 << "best frame time: " << mCurrentViewport->getTarget()->getBestFrameTime() << ", " 504 << "worst frame time: " << mCurrentViewport->getTarget()->getWorstFrameTime() << "\n";*/ 551 << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << ", " 552 << "Found objects: " << (int)mVisible.size() << "\n"; 505 553 506 554 LogManager::getSingleton().logMessage(d.str()); … … 512 560 { 513 561 // for correct rendering, transparents must be rendered after hierarchical culling 514 if (!mSkipTransparents) 515 { 516 OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList); 562 // => do nothing 563 if (NORMAL_RENDER_HACK || !mSkipTransparents) 564 { 565 SceneManager::renderObjects(objs, doLightIteration, manualLightList); 517 566 } 518 567 } … … 520 569 bool VisibilityOctreeSceneManager::validatePassForRendering(Pass* pass) 521 570 { 571 if (NORMAL_RENDER_HACK) 572 { 573 return SceneManager::validatePassForRendering(pass); 574 } 575 522 576 // skip all but first pass if we are doing the depth pass 523 if ((mIsDepthPassPhase || mIsItemBufferPhase) && pass->getIndex() > 0)577 if ((mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() > 0)) 524 578 { 525 579 return false; 526 580 } 581 // all but first pass 582 /*else if ((!mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() != 0)) 583 { 584 return false; 585 }*/ 586 527 587 return SceneManager::validatePassForRendering(pass); 528 588 } … … 530 590 void VisibilityOctreeSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 531 591 { 532 if ( !mIsItemBufferPhase)592 if (NORMAL_RENDER_HACK || !mIsItemBufferPhase) 533 593 { 534 594 OctreeSceneManager::renderQueueGroupObjects(pGroup); … … 536 596 } 537 597 538 //-- renders item buffer598 //-- item buffer: render objects using false colors 539 599 540 600 // Iterate through priorities … … 562 622 continue; 563 623 564 // Render only first pass 624 // Render only first pass of renderable as false color 565 625 if (ipass->first->getIndex() > 0) 566 626 continue; … … 573 633 for (irend = rendList->begin(); irend != irendend; ++irend) 574 634 { 635 if (0) 636 { 575 637 std::stringstream d; d << "itembuffer, pass name: " << 576 638 ipass->first->getParent()->getParent()->getName(); 577 639 578 640 LogManager::getSingleton().logMessage(d.str()); 641 } 579 642 580 643 RenderSingleObjectForItemBuffer(*irend, ipass->first); … … 582 645 } 583 646 584 //-- TRANSPARENT LOOP: must be handled differently 647 //-- TRANSPARENT LOOP: must be handled differently from solids 585 648 586 649 // transparents are treated either as solids or completely discarded … … 645 708 646 709 647 // Render a single object, this will set up auto params if required710 // render a single object, this will set up auto params if required 648 711 renderSingleObject(rend, usedPass, false, &nullLightList); 649 712 } … … 678 741 mLeavePassesInQueue = 0; 679 742 680 if ( 0 &&!mUseDepthPass && !mUseItemBuffer)743 if (!mUseDepthPass && !mUseItemBuffer) 681 744 { 682 745 if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) … … 689 752 mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 690 753 691 // just render ambient passes754 // just render ambient stuff 692 755 mIlluminationStage = IRS_AMBIENT; 693 756 getRenderQueue()->setSplitPassesByLightingType(true); … … 708 771 } 709 772 710 // skip rendering transparents inthe hierarchical culling773 // skip rendering transparents during the hierarchical culling 711 774 // (because they will be rendered afterwards) 712 mSkipTransparents = mUseDepthPass ||713 (m LeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES);775 mSkipTransparents = 776 (mIsDepthPassPhase || (mLeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES)); 714 777 715 778 // -- initialise interface for rendering traversal of the hierarchy … … 721 784 mLeavePassesInQueue); 722 785 723 std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;724 LogManager::getSingleton().logMessage(d.str());725 786 } 726 787 //----------------------------------------------------------------------- … … 730 791 } 731 792 //----------------------------------------------------------------------- 732 void VisibilityOctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 793 Entity* VisibilityOctreeSceneManager::createEntity(const String& entityName, 794 const String& meshName) 795 { 796 Entity *ent = SceneManager::createEntity(entityName, meshName); 797 798 for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 799 { 800 ent->getSubEntity(i)->setId(mCurrentEntityId); 801 } 802 803 // increase counter of entity id values 804 ++ mCurrentEntityId; 805 806 return ent; 807 } 808 //----------------------------------------------------------------------- 809 void VisibilityOctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects( 810 RenderQueueGroup* pGroup) 733 811 { 734 812 // only render solid passes during hierarchical culling -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp
r726 r865 9 9 #include <OgreEntity.h> 10 10 #include <OgreSubEntity.h> 11 11 #include <OgreConfigFile.h> 12 12 13 13 // normal terrain rendering … … 62 62 63 63 mDepthPass = depthMat->getTechnique(0)->getPass(0); 64 65 64 mDepthPass->setColourWriteEnabled(false); 66 65 mDepthPass->setDepthWriteEnabled(true); 67 66 mDepthPass->setLightingEnabled(false); 68 //mDepthPass->setDepthCheckEnabled(true);69 67 } 70 68 else … … 290 288 291 289 if (mShowVisualization) 290 { 292 291 // disable illumination stage to prevent rendering shadows 293 292 mIlluminationStage = IRS_NONE; 293 } 294 294 295 295 // standard rendering for shadow maps because of performance … … 300 300 else //-- the hierarchical culling algorithm 301 301 { 302 // from TerrainSceneManager 302 // this is also called in TerrainSceneManager: really 303 // nexessary? 303 304 mDestRenderSystem -> setLightingEnabled(false); 304 305 … … 379 380 380 381 OctreeSceneManager::_renderVisibleObjects(); 381 } 382 } // hierarchical culling 382 383 383 384 // HACK: set the new render level index, important to avoid cracks … … 389 390 390 391 getRenderQueue()->clear(); // finally clear render queue 391 if ( 0) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ...392 if (1) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 392 393 393 394 if (0) WriteLog(); // write out stats … … 594 595 if (NORMAL_RENDER_HACK || !mIsItemBufferPhase) 595 596 { 596 SceneManager::renderQueueGroupObjects(pGroup);597 OctreeSceneManager::renderQueueGroupObjects(pGroup); 597 598 return; 598 599 } … … 639 640 std::stringstream d; d << "itembuffer, pass name: " << 640 641 ipass->first->getParent()->getParent()->getName(); 642 641 643 LogManager::getSingleton().logMessage(d.str()); 642 644 } … … 726 728 mIsDepthPassPhase = mUseDepthPass; 727 729 730 mIsHierarchicalCulling = true; // during hierarchical culling 731 728 732 // item buffer needs full ambient lighting to use item colors as unique id 729 733 if (mUseItemBuffer) … … 737 741 // for rendering AFTER hierarchical culling, i.e., passes which need 738 742 // a special rendering order 743 739 744 mLeavePassesInQueue = 0; 740 745 … … 752 757 // just render ambient stuff 753 758 mIlluminationStage = IRS_AMBIENT; 759 getRenderQueue()->setSplitPassesByLightingType(true); 754 760 } 755 761 … … 837 843 } 838 844 } 839 else 845 else // render the rest of the passes 840 846 { 841 847 OctreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(pGroup);
Note: See TracChangeset
for help on using the changeset viewer.