Changeset 147
- Timestamp:
- 06/22/05 18:35:55 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/CoherentHierarchicalCullingManager.h
r146 r147 25 25 26 26 protected: 27 /** Decides wether occlusion query should be issued depending on some27 /** Decides if node is considered to be visible depeding on the 28 28 assumed visibility factor. 29 @returns if occlusion query should be issued29 @returns if node is considered to be visible 30 30 */ 31 bool Decide QueryTest(HierarchyNode *node) const;31 bool DecideVisible(HierarchyNode *node) const; 32 32 33 33 unsigned int mAssumedVisibility; … … 35 35 mAssumedVisibility. 36 36 */ 37 unsignedint mThreshold;37 int mThreshold; 38 38 }; 39 39 -
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r146 r147 1 1 #include "CoherentHierarchicalCullingManager.h" 2 //#include <OgreLogManager.h>2 #include <OgreLogManager.h> 3 3 4 4 namespace GtpVisibility { … … 55 55 if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) 56 56 { 57 mNumFrustumCulledNodes ++;57 ++ mNumFrustumCulledNodes; 58 58 59 if (mVisualizeCulledNodes)59 if (mVisualizeCulledNodes) 60 60 { 61 61 mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); … … 79 79 bool wasVisible = mHierarchyInterface->IsNodeVisible(node) && 80 80 (mHierarchyInterface->LastVisited(node) == mHierarchyInterface->GetFrameId() - 1); 81 81 // if visibility is assumed to be true in this frame 82 bool assumeVisible = wasVisible && (mAssumedVisibility > 0) && DecideVisible(node); 83 82 84 // identify nodes that we cannot skip queries for 83 85 // geometry not only in leaves => test for renderable geometry 84 86 bool issueQuery = !wasVisible || 85 (mHierarchyInterface->HasGeometry(node) && 86 (!mAssumedVisibility || DecideQueryTest(node))); 87 88 // reset node's visibility classification 89 mHierarchyInterface->SetNodeVisible(node, false); 87 (mHierarchyInterface->HasGeometry(node) && !assumeVisible); 88 89 // reset node's visibility classification 90 mHierarchyInterface->SetNodeVisible(node, !issueQuery && assumeVisible); 90 91 91 92 // update node's visited flag … … 95 96 if (issueQuery) 96 97 { 97 mNumQueriesIssued ++;98 ++ mNumQueriesIssued; 98 99 99 100 queryQueue.push(QueryPair(node, mHierarchyInterface-> 100 101 IssueOcclusionQuery(node, wasVisible))); 101 102 } 102 103 103 104 // always traverse a node if it was visible 104 105 if (wasVisible) … … 117 118 mThreshold = 0; 118 119 119 if (mAssumedVisibility )120 if (mAssumedVisibility > 0) 120 121 { 121 mThreshold = RAND_MAX / mAssumedVisibility;122 mThreshold = RAND_MAX - RAND_MAX / mAssumedVisibility; 122 123 } 124 //std::stringstream d; d << "*** setting assumed vis: " << mAssumedVisibility; Ogre::LogManager::getSingleton().logMessage(d.str()); 123 125 } 124 126 //----------------------------------------------------------------------- 125 bool CoherentHierarchicalCullingManager::Decide QueryTest(HierarchyNode *node) const127 bool CoherentHierarchicalCullingManager::DecideVisible(HierarchyNode *node) const 126 128 { 129 /*bool result = rand() < mThreshold; 130 std::stringstream d; d << "Assumed vis: " << mAssumedVisibility << ", result: " << result; 131 Ogre::LogManager::getSingleton().logMessage(d.str()); return result;*/ 132 127 133 return rand() < mThreshold; 128 134 } -
trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
r139 r147 17 17 18 18 if (!mHierarchyInterface->CheckFrustumVisible(node)) 19 { //if (mHierarchyInterface->mIsShadowPass)20 mNumFrustumCulledNodes ++;19 { 20 ++ mNumFrustumCulledNodes; 21 21 22 22 if (mVisualizeCulledNodes) -
trunk/VUT/GtpVisibility/src/VisibilityManager.cpp
r146 r147 13 13 mQueryManager(new DummyQueryManager(NULL)), 14 14 mPreprocessingManager(new DummyPreprocessingManager(NULL)), 15 mVisibilityEnvironment(visEnvironment) 15 mVisibilityEnvironment(visEnvironment), 16 mAssumedVisibility(0) 16 17 { 17 18 SetCullingManager(VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING); -
trunk/VUT/Ogre/resources/VisibilityDemo.overlay
r146 r147 46 46 element TextArea(Example/Visibility/AlgorithmInfo): Example/Visibility/Templates/BasicText 47 47 { 48 left 1 5548 left 170 49 49 top 5 50 50 width 90 … … 63 63 element TextArea(Example/Visibility/ThresholdInfo): Example/Visibility/Templates/BasicText 64 64 { 65 left 1 5565 left 170 66 66 top 20 67 67 width 90 … … 79 79 element TextArea(Example/Visibility/UseOptimizationInfo): Example/Visibility/Templates/BasicText 80 80 { 81 left 1 5581 left 170 82 82 top 35 83 83 width 90 … … 95 95 element TextArea(Example/Visibility/UseDepthPassInfo): Example/Visibility/Templates/BasicText 96 96 { 97 left 1 5597 left 170 98 98 top 50 99 99 width 90 … … 107 107 width 90 108 108 height 30 109 caption [ A] Assumed Visibility109 caption [8][9] Assumed Visibility 110 110 } 111 111 112 112 element TextArea(Example/Visibility/AssumedVisibilityInfo): Example/Visibility/Templates/BasicText 113 113 { 114 left 1 55114 left 170 115 115 top 65 116 116 width 90 -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r141 r147 223 223 else 224 224 { 225 // we interleave identification and rendering of objects 226 // in _renderVisibibleObjects 227 225 // if not the shadow pass we interleave identification 226 // and rendering of objects in _renderVisibibleObjects 227 if (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 228 mIlluminationStage == IRS_RENDER_TO_TEXTURE) 229 { 230 TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 231 } 228 232 // only shadow casters will be rendered in shadow texture pass 229 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 230 //InitVisibilityCulling(cam); 233 //mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 231 234 } 232 235 //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); … … 247 250 mIlluminationStage = IRS_NONE; 248 251 252 TerrainSceneManager::_renderVisibleObjects(); 253 254 mIlluminationStage = savedStage; 255 } 256 // normal rendering for shadow maps because of performance 257 else if (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 258 mIlluminationStage == IRS_RENDER_TO_TEXTURE) 259 { 249 260 TerrainSceneManager::_renderVisibleObjects(); 250 261 } … … 313 324 314 325 // set the new render level index afterwards => new level in the next frame 315 TerrainRenderable::setCurrentRenderLevelIndex(316 (TerrainRenderable::getCurrentRenderLevelIndex() + 1) % 10);326 int levelIdx = (TerrainRenderable::getCurrentRenderLevelIndex() + 1) % 10; 327 TerrainRenderable::setCurrentRenderLevelIndex(levelIdx); 317 328 318 329 getRenderQueue()->clear(); -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r146 r147 170 170 dynamic_cast<PlatformQueryManager *>(mVisibilityManager->GetQueryManager())-> 171 171 SetViewport(mWindow->getViewport(0)); 172 173 // reset statistics 174 resetStats(); 172 175 } 173 176 //----------------------------------------------------------------------- … … 528 531 writeFrames(); 529 532 533 float avgFps = (float)mAvgFps / (float)mFrameCount; 534 530 535 //-- write out stats for recorded walkthrough 531 536 std::stringstream d; 532 537 d << "Algorithm: " << currentAlgorithmCaptions[mCurrentAlgorithm] << "\n" 533 << "avg. FPS: " << mWindow->getAverageFPS() << "\n" 538 //<< "avg. FPS: " << mWindow->getAverageFPS() << "\n" 539 << "avg. FPS: " << avgFps << "\n" 534 540 << "best FPS: " << mWindow->getBestFPS() << "\n" 535 541 << "worst FPS: " << mWindow->getWorstFPS() << "\n" … … 564 570 mWindow->setDebugText("Replay"); 565 571 566 // reset, because we measure fps stats during walkthrough 572 // reset, because we measure fps stats during walkthrough (warning: average fps broken) 567 573 mWindow->resetStatistics(); 574 resetStats(); 568 575 569 576 //-- initialise frame data … … 630 637 } 631 638 //----------------------------------------------------------------------- 639 void TerrainFrameListener::resetStats() 640 { 641 mAvgFps = 0; 642 mFrameCount = 0; 643 } 644 //----------------------------------------------------------------------- 632 645 void TerrainFrameListener::updateStats() 633 646 { … … 635 648 char str[100]; 636 649 637 static String currFps = "Current FPS: "; 638 static String avgFps = "Average FPS: "; 639 static String bestFps = "Best FPS: "; 640 static String worstFps = "Worst FPS: "; 641 static String tris = "Triangle Count: "; 642 650 static String currFpsString = "Current FPS: "; 651 static String avgFpsString = "Average FPS: "; 652 static String bestFpsString = "Best FPS: "; 653 static String worstFpsString = "Worst FPS: "; 654 static String trisString = "Triangle Count: "; 655 656 mAvgFps += mWindow->getStatistics().lastFPS; 657 ++ mFrameCount; 658 659 float avgFps = (float)mAvgFps / (float)mFrameCount; 660 643 661 // update stats when necessary 644 662 try … … 651 669 const RenderTarget::FrameStats& stats = mWindow->getStatistics(); 652 670 653 guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS)); 654 guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS)); 655 guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS) 671 //guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS)); 672 guiAvg->setCaption(avgFpsString + StringConverter::toString(avgFps)); 673 guiCurr->setCaption(currFpsString + StringConverter::toString(stats.lastFPS)); 674 guiBest->setCaption(bestFpsString + StringConverter::toString(stats.bestFPS) 656 675 +" "+StringConverter::toString(stats.bestFrameTime)+" ms"); 657 guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)676 guiWorst->setCaption(worstFpsString + StringConverter::toString(stats.worstFPS) 658 677 +" "+StringConverter::toString(stats.worstFrameTime)+" ms"); 659 678 660 679 OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris"); 661 guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount));680 guiTris->setCaption(trisString + StringConverter::toString(stats.triangleCount)); 662 681 663 682 OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText"); -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r146 r147 126 126 protected: 127 127 128 void resetStats(); 129 128 130 /** Clamp camera to terrain. 129 131 */ … … 228 230 bool mShowQueryStats; 229 231 232 unsigned long mAvgFps; 233 unsigned long mFrameCount; 230 234 //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 231 235 };
Note: See TracChangeset
for help on using the changeset viewer.