Changeset 139
- Timestamp:
- 06/20/05 08:13:57 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 1 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
r130 r139 7 7 void CoherentHierarchicalCullingManager::RenderScene() 8 8 { 9 //InitFrame();10 9 QueryQueue queryQueue; 11 10 unsigned int visiblePixels = 0; -
trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
r115 r139 7 7 void FrustumCullingManager::RenderScene() 8 8 { 9 //InitFrame();10 11 9 while (!mHierarchyInterface->GetQueue()->empty()) 12 10 { -
trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
r115 r139 7 7 void StopAndWaitCullingManager::RenderScene() 8 8 { 9 //InitFrame();10 11 9 while (!mHierarchyInterface->GetQueue()->empty()) 12 10 { … … 21 19 22 20 if (!mHierarchyInterface->CheckFrustumVisible(node, intersects)) 23 {//if (mHierarchyInterface->mIsShadowPass) 24 mNumFrustumCulledNodes ++; 21 { 22 ++ mNumFrustumCulledNodes; 23 25 24 if (mVisualizeCulledNodes) 26 25 { … … 38 37 } 39 38 40 mNumQueriesIssued ++;39 ++ mNumQueriesIssued; 41 40 42 41 unsigned int visiblePixels = 0; … … 50 49 } 51 50 else 52 { //if (mHierarchyInterface->mIsShadowPass) 53 mNumQueryCulledNodes ++; 51 { 52 ++ mNumQueryCulledNodes; 53 54 54 if (mVisualizeCulledNodes) 55 55 { -
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r130 r139 53 53 */ 54 54 void InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam = NULL, 55 bool leaveTransparentsInQueue = false);55 int leavePassesInQueue = 0); 56 56 /** Checks if the node is visible from the current view frustum. 57 57 @param node the current node … … 162 162 163 163 bool mOnlyShadowCasters; 164 bool mLeaveTransparentsInQueue;164 int mLeavePassesInQueue; 165 165 bool mIsBoundingBoxQuery; 166 166 }; -
trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h
r130 r139 67 67 68 68 /** Prepares visualization of hierarchical culling. */ 69 void ShowVisualization(Camera *cam);69 void PrepareVisualization(Camera *cam); 70 70 OctreeHierarchyInterface *mHierarchyInterface; 71 71 GtpVisibility::VisibilityManager *mVisibilityManager; -
trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h
r133 r139 90 90 /** Fills render queue so that a visualization can be rendered. 91 91 */ 92 void ShowVisualization(Camera *cam); 92 void PrepareVisualization(Camera *cam); 93 94 void InitVisibilityCulling(Camera *cam); 95 93 96 94 97 OctreeHierarchyInterface *mHierarchyInterface; … … 96 99 97 100 bool mShowVisualization; 98 bool mSkipTransparents;99 101 bool mVisualizeCulledNodes; 100 102 … … 106 108 bool mRenderItemBuffer; 107 109 bool mEnableDepthWrite; 110 bool mSkipTransparents; 108 111 109 112 Pass *mDepthPass; … … 113 116 114 117 PlatformQueryManager *mQueryManager; 118 119 int mLeavePassesInQueue; 120 ShadowTechnique mSavedShadowTechnique; 115 121 }; 116 122 -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r135 r139 16 16 void OctreeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 17 17 { 18 mNumTraversedNodes ++;18 ++ mNumTraversedNodes; 19 19 20 20 Octree *octree = static_cast<Octree *>(node); … … 107 107 108 108 dynamic_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, 109 octant, mOnlyShadowCasters, mLeave TransparentsInQueue);109 octant, mOnlyShadowCasters, mLeavePassesInQueue); 110 110 111 111 mRenderedNodes.push_back(node); … … 134 134 AxisAlignedBox *OctreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 135 135 { 136 if (node != mPreviousNode)136 if (node != mPreviousNode) 137 137 { 138 138 mPreviousNode = node; 139 //static_cast<Octree *>(node)->_getCullBounds(&mBox);139 //static_cast<Octree *>(node)->_getCullBounds(&mBox); 140 140 mBox = static_cast<Octree *>(node)->_getWorldAABB(); 141 //std::stringstream d; d << mBox;LogManager::getSingleton().logMessage(d.str()); 141 142 } 142 143 -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r135 r139 13 13 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 14 14 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), mCamera(NULL), 15 mCullCamera(NULL), mOnlyShadowCasters(false), mLeave TransparentsInQueue(false),15 mCullCamera(NULL), mOnlyShadowCasters(false), mLeavePassesInQueue(0), 16 16 mIsBoundingBoxQuery(false) 17 17 { … … 131 131 //----------------------------------------------------------------------- 132 132 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, 133 Camera *cam, Camera *cullCam, bool leaveTransparentsInQueue)133 Camera *cam, Camera *cullCam, int leavePassesInQueue) 134 134 { 135 135 GtpVisibility::HierarchyInterface::InitFrame(root); 136 136 137 137 mPreviousNode = NULL; 138 mLeave TransparentsInQueue = leaveTransparentsInQueue;138 mLeavePassesInQueue = leavePassesInQueue; 139 139 140 140 mCamera = cam; 141 141 mCullCamera = cullCam ? cullCam : cam; 142 143 //if (mCullCamera != mCamera)144 // LogManager::getSingleton().logMessage("cullcamera is not camera");145 142 146 143 // create materials for node visualization … … 268 265 void PlatformHierarchyInterface::RenderGeometry(GtpVisibility::Mesh *geom) 269 266 { 270 mSceneManager->_renderMovableObject(geom, mLeave TransparentsInQueue);267 mSceneManager->_renderMovableObject(geom, mLeavePassesInQueue); 271 268 } 272 269 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r130 r139 19 19 void SceneNodeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 20 20 { 21 mNumTraversedNodes ++;21 ++ mNumTraversedNodes; 22 22 23 23 SceneNode *sceneNode = static_cast<SceneNode *>(node); … … 47 47 mRenderedNodes.push_back(node); 48 48 49 mSceneManager->_renderSceneNode(mCamera, sceneNode, mLeave TransparentsInQueue);49 mSceneManager->_renderSceneNode(mCamera, sceneNode, mLeavePassesInQueue); 50 50 } 51 51 #endif … … 151 151 { 152 152 Entity *ent = static_cast<Entity *>(movable); 153 //std::stringstream d; d << "ent " << ent->getName(); 154 //LogManager::getSingleton().logMessage(d.str()); 153 //std::stringstream d; d << "ent " << ent->getName(); LogManager::getSingleton().logMessage(d.str()); 155 154 geometryList->push_back(ent); 156 155 } -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r122 r139 21 21 mRenderNodesContentForViz(false), 22 22 mVisualizeCulledNodes(false), 23 mSkipTransparents(false),24 23 mDelayRenderTransparents(true), 25 mUseDepthPass(true) 24 mUseDepthPass(true), 25 mSkipTransparents(false) 26 26 { 27 27 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 101 101 } 102 102 //----------------------------------------------------------------------- 103 void VisibilityOctreeSceneManager:: ShowVisualization(Camera *cam)103 void VisibilityOctreeSceneManager::PrepareVisualization(Camera *cam) 104 104 { 105 105 // add player camera for visualization purpose 106 try { 106 try 107 { 107 108 Camera *c; 108 109 if ((c = getCamera("PlayerCam")) != NULL) … … 129 130 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 130 131 { 131 132 132 if (mRenderNodesForViz) 133 133 { … … 150 150 if (mShowVisualization) 151 151 { 152 ShowVisualization(cam);152 PrepareVisualization(cam); 153 153 } 154 154 else … … 189 189 leaveTransparentsInQueue); 190 190 191 // call initframe toreset culling manager stats191 // reset culling manager stats 192 192 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 193 193 … … 204 204 205 205 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 206 _deleteRenderedQueueGroups( false);206 _deleteRenderedQueueGroups(); 207 207 #endif 208 208 … … 272 272 return true; 273 273 } 274 if (key == " ShowVisualization")274 if (key == "PrepareVisualization") 275 275 { 276 276 mShowVisualization = (*static_cast<const bool *>(val)); -
trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp
r115 r139 43 43 mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress); 44 44 45 // call initframe toreset culling manager stats45 // reset culling manager stats 46 46 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 47 47 } … … 68 68 69 69 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 70 _deleteRenderedQueueGroups( false);70 _deleteRenderedQueueGroups(); 71 71 #endif 72 72 … … 84 84 85 85 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 86 //_deleteRenderedQueueGroups();86 _deleteRenderedQueueGroups(); 87 87 #endif 88 88 -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r137 r139 21 21 mRenderNodesContentForViz(false), 22 22 mVisualizeCulledNodes(false), 23 m SkipTransparents(false),23 mLeavePassesInQueue(0), 24 24 mDelayRenderTransparents(true), 25 25 mUseDepthPass(false), 26 26 mRenderItemBuffer(false), 27 27 mCurrentEntityId(0), 28 mEnableDepthWrite(true) 28 mEnableDepthWrite(true), 29 mSkipTransparents(false), 30 mSavedShadowTechnique(SHADOWTYPE_NONE) 29 31 { 30 32 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 32 34 33 35 mVisibilityManager->SetQueryManager(mQueryManager); 36 34 37 //mDisplayNodes = true; 35 38 //mShowBoundingBoxes = true; … … 97 100 } 98 101 //----------------------------------------------------------------------- 99 void VisibilityTerrainSceneManager:: ShowVisualization(Camera *cam)102 void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam) 100 103 { 101 104 // add player camera for visualization purpose … … 128 131 if (mRenderNodesForViz) 129 132 { 130 //getRenderQueue()->addRenderable(*it); 133 OctreeNode *node = *it; 134 if ((node->numAttachedObjects() > 0) && (node->numChildren() == 0) 135 && node->getAttachedObject(0)->getMovableType() == "Entity") 136 getRenderQueue()->addRenderable(node); 131 137 132 138 // addbounding boxes instead of node itself 133 (*it)->_addBoundingBoxToQueue(getRenderQueue());139 //(*it)->_addBoundingBoxToQueue(getRenderQueue()); 134 140 } 135 141 if (mRenderNodesContentForViz) … … 143 149 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 144 150 { 145 //Pass *usedPass = ((mRenderDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); // setting vertex program is not efficient 151 // TODO: setting vertex program is not efficient 152 //Pass *usedPass = ((mRenderDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); 146 153 147 154 // set depth fill pass only if depth write enabled … … 182 189 183 190 bool IsDepthWrite = usedPass->getDepthWriteEnabled(); 191 184 192 // global option which enables / disables depth writes 185 193 if (!mEnableDepthWrite) … … 187 195 usedPass->setDepthWriteEnabled(false); 188 196 } 189 190 197 //else if (mIsItemBufferPass) {usedPass = mItemBufferPass;} 191 198 … … 207 214 { 208 215 // needs full ambient lighting for item colors to be exact 209 /*if (mRenderItemBuffer) 210 { setAmbientLight(ColourValue(1,1,1,1)); }*/ 216 //if (mRenderItemBuffer) {setAmbientLight(ColourValue(1,1,1,1));} 211 217 212 218 //-- show visible scene nodes and octree bounding boxes from last frame 213 219 if (mShowVisualization) 214 220 { 215 ShowVisualization(cam); 216 } 217 221 PrepareVisualization(cam); 222 } 223 else 224 { 225 // we interleave identification and rendering of objects 226 // in _renderVisibibleObjects 227 228 // only shadow casters will be rendered in shadow texture pass 229 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 230 //InitVisibilityCulling(cam); 231 } 218 232 //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 219 233 220 234 mVisible.clear(); 221 235 mBoxes.clear(); 222 223 // if there is no depth pass => 224 // we interleave identification and rendering of objects 225 // in _renderVisibibleObjects 226 227 // only shadow casters will be rendered in shadow texture pass 228 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 229 230 bool leaveTransparentsInQueue = mDelayRenderTransparents && !mUseDepthPass; 231 232 // possible two cameras (one for culling, one for rendering) 233 mHierarchyInterface->InitFrame(mOctree, cam, //mCameraInProgress, 234 mCullCamera ? getCamera("CullCamera") : NULL, 235 leaveTransparentsInQueue); 236 236 237 } 237 238 //----------------------------------------------------------------------- 238 239 void VisibilityTerrainSceneManager::_renderVisibleObjects() 239 240 { 240 // increase terrain renderlevel241 int renderLevel = TerrainRenderable::getCurrentRenderLevelIndex() + 1;242 243 if (TerrainRenderable::getCurrentRenderLevelIndex() >= 10)244 { // max. 10 different renderlevels245 renderLevel = 0;246 }247 248 241 // visualization: apply standard rendering 249 242 if (mShowVisualization) 250 243 { 244 IlluminationRenderStage savedStage = mIlluminationStage; 245 246 // disable illumination stage so we have no shadow rendering 247 mIlluminationStage = IRS_NONE; 248 251 249 TerrainSceneManager::_renderVisibleObjects(); 252 TerrainRenderable::setCurrentRenderLevelIndex(renderLevel); 253 return; 254 } 255 256 InitDepthPass(); // create material for depth pass 257 InitItemBufferPass(); // create material for item buffer pass 258 259 //-- hierarchical culling 260 // the objects of different layers (e.g., background, scene, 261 // overlay) must be identified and rendered one after another 262 263 // frame initialisation to reset culling manager stats 264 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 265 266 mSkipTransparents = false; 267 268 //-- render background, in case there is one 269 clearSpecialCaseRenderQueues(); 270 addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 271 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 272 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 273 274 TerrainSceneManager::_renderVisibleObjects(); 250 } 251 else 252 { 253 //-- hierarchical culling 254 // the objects of different layers (e.g., background, scene, 255 // overlay) must be identified and rendered one after another 256 257 //-- render all early skies 258 clearSpecialCaseRenderQueues(); 259 addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 260 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 261 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 262 263 TerrainSceneManager::_renderVisibleObjects(); 275 264 276 265 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 277 _deleteRenderedQueueGroups(false);266 _deleteRenderedQueueGroups(); 278 267 #endif 279 268 280 //-- render visible objects (i.e., all but overlay and skies late) 281 clearSpecialCaseRenderQueues(); 282 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 283 addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 284 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 285 286 // transparents are skipped from hierarchical rendering 287 // => they need sorting, thus we render them afterwards 288 mSkipTransparents = mDelayRenderTransparents; 289 290 // set state for depth pass 291 mRenderDepthPass = mUseDepthPass; 292 293 /** 294 * the hierarchical culling algorithm 295 * for depth pass: will just find objects and update depth buffer 296 * for delayed rendering: will render all but transparents 297 **/ 298 299 mVisibilityManager->ApplyVisibilityCulling(); 300 301 // delete remaining renderables from queue (or all but transparents) 269 //-- prepare queue for visible objects (i.e., all but overlay and skies late) 270 clearSpecialCaseRenderQueues(); 271 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 272 addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 273 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 274 275 276 //-- set all necessary parameters for hierarchical visibility culling and rendering 277 InitVisibilityCulling(mCameraInProgress); 278 279 /** 280 * the hierarchical culling algorithm 281 * if using depth pass: will just find objects and update depth buffer 282 * for "delayed" rendering: will render some passes afterwards, e.g. transparents 283 **/ 284 285 mVisibilityManager->ApplyVisibilityCulling(); 286 287 // delete remaining renderables from queue (all not in mLeavePassesInQueue) 302 288 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 303 _deleteRenderedQueueGroups(mSkipTransparents);289 _deleteRenderedQueueGroups(mLeavePassesInQueue); 304 290 #endif 305 291 306 // for depth pass: add visible nodes found with the visibility culling 307 if (mUseDepthPass) 308 { 309 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 310 { 311 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 312 } 292 //-- reset parameters 313 293 mRenderDepthPass = false; 314 } 315 316 mSkipTransparents = false; 317 318 //-- now we can render all remaining queue objects 319 // for depth pass: all 320 // for delayed rendering: transparents, overlay 321 clearSpecialCaseRenderQueues(); 322 TerrainSceneManager::_renderVisibleObjects(); 323 324 TerrainRenderable::setCurrentRenderLevelIndex(renderLevel); 294 mSkipTransparents = false; 295 mLeavePassesInQueue = 0; 296 mShadowTechnique = mSavedShadowTechnique; 297 298 299 // add visible nodes found by the visibility culling algorithm 300 if (mUseDepthPass) 301 { 302 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 303 { 304 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 305 } 306 } 307 308 //-- now we can render all remaining queue objects 309 // for depth pass, transparents, overlay 310 clearSpecialCaseRenderQueues(); 311 TerrainSceneManager::_renderVisibleObjects(); 312 } 313 314 // set the new render level index afterwards => new level in the next frame 315 TerrainRenderable::setCurrentRenderLevelIndex( 316 (TerrainRenderable::getCurrentRenderLevelIndex() + 1) % 10); 317 325 318 getRenderQueue()->clear(); 326 319 //WriteLog(); // write out stats … … 346 339 return true; 347 340 } 348 if (key == " ShowVisualization")341 if (key == "PrepareVisualization") 349 342 { 350 343 mShowVisualization = (*static_cast<const bool *>(val)); … … 453 446 } 454 447 //----------------------------------------------------------------------- 455 void VisibilityTerrainSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 456 bool doLightIteration, const LightList* manualLightList) 448 void VisibilityTerrainSceneManager::renderObjects( 449 const RenderPriorityGroup::TransparentRenderablePassList& objs, 450 bool doLightIteration, const LightList* manualLightList) 457 451 { 458 452 // for correct rendering, transparents must be rendered after hierarchical culling … … 519 513 std::stringstream d; d << "itembuffer, pass name: " << 520 514 ipass->first->getParent()->getParent()->getName(); 521 //<< ", renderable name: " << irend-> 522 515 523 516 LogManager::getSingleton().logMessage(d.str()); 524 517 525 //if(ipass->first->getParent()->getParent()->getName() == "Examples/Athene") 526 //<< ", renderable name: " << irend-> 527 RenderSingleObjectForItemBuffer(*irend, ipass->first); 528 //RenderSingleObjectForOcclusionQuery( 518 RenderSingleObjectForItemBuffer(*irend, ipass->first); 529 519 } 530 520 } … … 556 546 mItemBufferPass->setAmbient(ColourValue(0, 1, 1)); 557 547 //mItemBufferPass->setDiffuse(ColourValue(0, col, 0)); 558 //mItemBufferPass->setSpecular(ColourValue(0, col, 0));559 //mItemBufferPass->_load();548 //mItemBufferPass->setSpecular(ColourValue(0, col, 0)); 549 //mItemBufferPass->_load(); 560 550 561 551 // set vertex program of current pass … … 579 569 } 580 570 581 //LogManager::getSingleton().logMessage("has vertex program");582 571 Pass *usedPass = setPass(mItemBufferPass); 583 572 //Pass *usedPass = setPass(pass); 584 std::stringstream d;585 d << "item buffer id: " << rend->getId() << ", col: " << col;573 574 std::stringstream d; d << "item buffer id: " << rend->getId() << ", col: " << col; 586 575 LogManager::getSingleton().logMessage(d.str()); 587 576 … … 607 596 return ent; 608 597 } 609 598 //----------------------------------------------------------------------- 599 void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam) 600 { 601 InitDepthPass(); // create material for depth pass 602 InitItemBufferPass(); // create material for item buffer pass 603 604 // save shadow technique so after first pass it can be reset 605 mSavedShadowTechnique = mShadowTechnique; 606 607 608 // set passes which should be stored in render queue for rendering afterwards 609 mLeavePassesInQueue = 0; 610 611 /* if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) 612 { 613 mShadowTechnique = SHADOWTYPE_NONE; 614 615 if (!mUseDepthPass) 616 { 617 // TODO: remove this 618 mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW; 619 620 mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DECAL; 621 mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DIFFUSE_SPECULAR; 622 mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 623 } 624 } 625 if (mShadowTechnique == SHADOWTYPE_STENCIL_MODULATIVE) 626 { 627 mShadowTechnique = SHADOWTYPE_NONE; 628 629 if (!mUseDepthPass) 630 { 631 mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW; 632 mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 633 } 634 } 635 */ 636 if (mDelayRenderTransparents && (!mUseDepthPass)) 637 { 638 mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 639 } 640 std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue; 641 LogManager::getSingleton().logMessage(d.str()); 642 643 // possible two cameras (one for culling, one for rendering) 644 mHierarchyInterface->InitFrame(mOctree, cam, 645 mCullCamera ? getCamera("CullCamera") : NULL, 646 mLeavePassesInQueue); 647 648 649 // reset culling manager stats 650 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 651 652 // set depth pass flag before rendering 653 mRenderDepthPass = mUseDepthPass; 654 655 // set flag for skipping transparents for this rendering pass 656 mSkipTransparents = mUseDepthPass || (mLeavePassesInQueue & 657 RenderPriorityGroup::TRANSPARENT_PASSES); 658 } 659 660 //----------------------------------------------------------------------- 661 /*void VisibilityTerrainSceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup) 662 { 663 // Basic render loop 664 // Iterate through priorities 665 RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator(); 666 667 while (groupIt.hasMoreElements()) 668 { 669 RenderPriorityGroup* pPriorityGrp = groupIt.getNext(); 670 671 // Sort the queue first 672 pPriorityGrp->sort(mCameraInProgress); 673 674 //TODO: render other splid passes for shadows 675 // Do solids 676 renderObjects(pPriorityGrp->_getSolidPassesNoShadows(), true); 677 678 // do solid passes no shadows if addititive stencil shadows 679 if (mSavedShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) 680 renderObjects(pPriorityGrp->_getSolidPassesNoShadows(), true); 681 682 // Do transparents 683 renderObjects(pPriorityGrp->_getTransparentPasses(), true); 684 685 686 }// for each priority 687 } 688 */ 610 689 } // namespace Ogre -
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r133 r139 94 94 95 95 /***********************************************/ 96 /* TerrainFrameListener implementation 96 /* TerrainFrameListener implementation */ 97 97 /***********************************************/ 98 98 //----------------------------------------------------------------------- … … 294 294 mShowVisualization = !mShowVisualization; 295 295 296 mSceneMgr->setOption(" ShowVisualization", &mShowVisualization);296 mSceneMgr->setOption("PrepareVisualization", &mShowVisualization); 297 297 mSceneMgr->setOption("VisualizeCulledNodes", &mVisualizeCulledNodes); 298 298 } -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r137 r139 75 75 mCullCamera(false), 76 76 mRecord(false), 77 m UseShadows(false),77 mShowShadows(false), 78 78 mShowHelp(false), 79 79 mDisplayCameraDetails(false), … … 159 159 mSceneMgr->setOption("ShowOctree", &mShowOctree); 160 160 mSceneMgr->setOption("CullCamera", &mCullCamera); 161 mSceneMgr->setOption(" ShowVisualization", &mShowVisualization);161 mSceneMgr->setOption("PrepareVisualization", &mShowVisualization); 162 162 163 163 // TODO: change this (does not work with other scene manager plugins) … … 257 257 } 258 258 259 // mInputDevice->capture(); 259 if (mDisplayCameraDetails) 260 { 261 // Print camera details 262 mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) + 263 " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation())); 264 } 260 265 261 266 //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly … … 706 711 void TerrainFrameListener::toggleShowViz() 707 712 { 708 mShowVisualization = !mShowVisualization; 709 mVisualizeCulledNodes = !mVisualizeCulledNodes; 710 713 mVisualizeCulledNodes = mShowVisualization = !mShowVisualization; 714 711 715 // create viewport with priority VIZ_VIEWPORT_Z_ORDER: 712 716 // will be rendered over standard viewport … … 721 725 // Alter the camera aspect ratio to match the viewport 722 726 mVizCamera->setAspectRatio(Real(vizvp->getActualWidth()) / 723 Real(vizvp->getActualHeight()));727 Real(vizvp->getActualHeight())); 724 728 725 729 mSceneMgr->setOption("VisualizeCulledNodes", &mVisualizeCulledNodes); … … 733 737 mSceneMgr->setSkyPlane(true, plane, "Examples/TransparentTest", 4000, 75, false); 734 738 */ 735 736 739 } 737 740 else 738 741 { 742 // remove visualization viewport 739 743 mWindow->removeViewport(VIZ_VIEWPORT_Z_ORDER); 740 // if octree was enabled for visualization purpose, reset now 744 745 // octree bounding boxes are shown for visualization purpose, reset now 741 746 mSceneMgr->setOption("ShowOctree", &mShowOctree); 742 747 } 743 748 } 744 749 //----------------------------------------------------------------------- 745 void TerrainFrameListener::toggle UseShadows()746 { 747 m UseShadows = !mUseShadows;748 749 mSunLight->setCastShadows(m UseShadows);750 751 if (m UseShadows)750 void TerrainFrameListener::toggleShowShadows() 751 { 752 mShowShadows = !mShowShadows; 753 754 mSunLight->setCastShadows(mShowShadows); 755 756 if (mShowShadows) 752 757 { 753 758 mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE); 759 //mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_MODULATIVE); 760 //mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE); 754 761 } 755 762 else … … 805 812 break; 806 813 case KC_S: 807 toggle UseShadows();814 toggleShowShadows(); 808 815 break; 809 816 … … 857 864 break; 858 865 } 859 860 if (mDisplayCameraDetails)861 {862 // Print camera details863 mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) +864 " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation()));865 }866 866 867 867 CEGUI::System::getSingleton().injectKeyDown(e->getKey()); -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r135 r139 98 98 void toggleShowStats(); 99 99 100 void toggle UseShadows();100 void toggleShowShadows(); 101 101 void toggleDisplayCameraDetails(); 102 102 void takeScreenShot(); … … 175 175 bool mCullCamera; 176 176 bool mRecord; 177 bool m UseShadows;177 bool mShowShadows; 178 178 bool mVisualizeCulledNodes; 179 179 bool mShowHelp; -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r137 r139 84 84 { 85 85 // Set ambient light 86 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 86 mAmbientLight = ColourValue(0.5, 0.5, 0.5); 87 mSceneMgr->setAmbientLight(mAmbientLight); 87 88 88 89 //-- create light … … 100 101 mSunLight->setDirection(dir); 101 102 //mSunLight->setDirection(Vector3::NEGATIVE_UNIT_Y); 102 103 103 mSunLight->setDiffuseColour(1, 1, 1); 104 104 mSunLight->setSpecularColour(1, 1, 1); … … 137 137 */ 138 138 mSceneMgr->setShadowTextureSettings(1024, 2); 139 /* if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_HWRENDER_TO_TEXTURE))140 { // In D3D, use a 1024x1024 shadow texture141 mSceneMgr->setShadowTextureSettings(1024, 2); } else {142 // Use 512x512 texture in GL since we can't go higher than the window res143 mSceneMgr->setShadowTextureSettings(512, 2);}144 */145 146 //mSceneMgr->setShadowColour(ColourValue(0, 0, 0));147 139 mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5)); 148 // 140 //mSceneMgr->setShowDebugShadows(true); 149 141 150 142 … … 220 212 const bool nShowViz = !showViz; 221 213 222 // ambient light must be full for visualization 214 mSavedShadowTechnique = mSceneMgr->getShadowTechnique(); 215 mSavedAmbientLight = mSceneMgr->getAmbientLight(); 216 217 // -- ambient light must be full for visualization, shadows disabled 223 218 if (showViz) 224 219 { 225 220 mSceneMgr->setAmbientLight(ColourValue(1, 1, 1)); 226 } 227 else 228 { 229 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 230 } 231 232 mSceneMgr->setOption("ShowVisualization", &showViz); 221 mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE); 222 } 223 224 mSceneMgr->setOption("PrepareVisualization", &showViz); 233 225 mSceneMgr->setOption("SkyBoxEnabled", &nShowViz); 234 226 //mSceneMgr->setOption("SkyPlaneEnabled", &showViz); … … 239 231 void VisualizationRenderTargetListener::postRenderTargetUpdate(const RenderTargetEvent &evt) 240 232 { 233 // reset values 234 mSceneMgr->setShadowTechnique(mSavedShadowTechnique); 235 mSceneMgr->setAmbientLight(mSavedAmbientLight); 236 241 237 RenderTargetListener::postRenderTargetUpdate(evt); 242 238 } -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r133 r139 3 3 4 4 #include "CEGUIForwardRefs.h" 5 #include <OgreRenderTargetListener.h> 5 6 #include "ExampleApplication.h" 7 6 8 #include "OgreTerrainContentGenerator.h" 7 8 #include <OgreRenderTargetListener.h>9 9 #include "TerrainFrameListener.h" 10 10 … … 19 19 20 20 SceneManager *mSceneMgr; 21 22 ShadowTechnique mSavedShadowTechnique; 23 ColourValue mSavedAmbientLight; 21 24 }; 22 25 … … 54 57 SceneNode *mCamNode; 55 58 Light *mSunLight; 56 VisualizationRenderTargetListener *mRenderTargetListener;57 59 58 60 TerrainFrameListener *mTerrainFrameListener; 61 ColourValue mAmbientLight; 62 //VisualizationRenderTargetListener *mVizRenderTargetListener; 59 63 60 64 private: -
trunk/VUT/work/ogre_changes/OgreMain/include/OgreRenderQueueSortingGrouping.h
r115 r139 197 197 void clear(void); 198 198 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 199 199 200 /** Clears solids in this group of renderables. Leaves transparents in group. 200 201 */ 201 202 void clearSolids(void); 203 204 enum {SOLID_PASSES = 1, 205 SOLID_PASSES_DECAL = 2, 206 SOLID_PASSES_DIFFUSE_SPECULAR = 4, 207 SOLID_PASSES_NOSHADOW = 8, 208 TRANSPARENT_PASSES = 16}; 209 210 /** Clears passes determined by parameter. 211 @param passes can be one or several (combined by |) of: 212 SOLID_PASSES 213 SOLID_PASSES_DECAL 214 SOLID_PASSES_DIFFUSE_SPECULAR 215 SOLID_PASSES_NOSHADOW 216 TRANSPARENT_PASSES 217 */ 218 void clear(const int leavePassesInQueue); 202 219 #endif // GTP_VISIBILITY_MODIFIED_OGRE 203 220 /** Sets whether or not the queue will split passes by their lighting type, … … 306 323 } 307 324 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 325 void clear(int passes) 326 { 327 PriorityMap::iterator i, iend; 328 iend = mPriorityGroups.end(); 329 for (i = mPriorityGroups.begin(); i != iend; ++i) 330 { 331 i->second->clear(passes); 332 } 333 334 } 308 335 /** Clears only solid renderables. Leaves transparents in queue. */ 309 336 void clearSolids(void) -
trunk/VUT/work/ogre_changes/OgreMain/include/OgreSceneManager.h
r131 r139 128 128 @param node scene node to be rendered 129 129 @param cam current camera 130 @param leave TransparentsInQueue if only solid objects should be rendered131 */ 132 void _renderSceneNode(Camera *cam, SceneNode *node, bool leaveTransparentsInQueue = false);130 @param leavePassesInQueue list of passes which are left in queue 131 */ 132 void _renderSceneNode(Camera *cam, SceneNode *node, const int leavePassesInQueue = 0); 133 133 /** deletes all processed queues 134 @remark clears render queues after rendering scene node 135 */ 136 void _deleteRenderedQueueGroups(bool leaveTransparentsInQueue); 134 @param leavePassesInQueue pass list which is not deleted from queue 135 @remark used to clear render queues before rendering scene node 136 */ 137 void _deleteRenderedQueueGroups(int leavePassesInQueue = 0); 137 138 /** Internal method used by _renderVisibleObjects to deal with renderables 138 139 which override the camera's own view / projection materices. … … 156 157 /** Renders an Ogre MovableObject. 157 158 */ 158 void _renderMovableObject(MovableObject *mov, const bool leaveTransparentsInQueue);159 void _renderMovableObject(MovableObject *mov, const int leavePassesInQueue); 159 160 160 161 #endif // GTP_VISIBILITY_MODIFIED_OGRE -
trunk/VUT/work/ogre_changes/OgreMain/src/OgreRenderQueueSortingGrouping.cpp
r115 r139 280 280 void RenderPriorityGroup::clearSolids(void) 281 281 { 282 /*SolidRenderablePassMap::iterator i, iend;282 /*SolidRenderablePassMap::iterator i, iend; 283 283 // Delete queue groups which are using passes which are to be 284 284 // deleted, we won't need these any more and they clutter up … … 313 313 clearSolidPassMap(mSolidPassesNoShadow); 314 314 } 315 //----------------------------------------------------------------------- 316 void RenderPriorityGroup::clear(const int leavePassesInQueue) 317 { 318 SolidRenderablePassMap::iterator i, iend; 319 320 // -- standard method if no passes are left in queue 321 if (leavePassesInQueue == 0) 322 { 323 clear(); 324 return; 325 } 326 327 // We do not clear the unchanged solid pass maps, only the contents of each list 328 // This is because we assume passes are reused a lot and it saves resorting 329 if (!(leavePassesInQueue & SOLID_PASSES)) 330 clearSolidPassMap(mSolidPasses); 331 if (!(leavePassesInQueue & SOLID_PASSES_DECAL)) 332 clearSolidPassMap(mSolidPassesDecal); 333 if (!(leavePassesInQueue & SOLID_PASSES_DIFFUSE_SPECULAR)) 334 clearSolidPassMap(mSolidPassesDiffuseSpecular); 335 if (!(leavePassesInQueue & SOLID_PASSES_NOSHADOW)) 336 clearSolidPassMap(mSolidPassesNoShadow); 337 338 if (!(leavePassesInQueue & TRANSPARENT_PASSES)) 339 mTransparentPasses.clear(); 340 } 315 341 #endif // GTP_VISIBILITY_MODIFIED_OGRE 316 342 //----------------------------------------------------------------------- -
trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneManager.cpp
r135 r139 1909 1909 1910 1910 itransend = objs.end(); 1911 for (itrans = objs.begin(); 1912 itrans != itransend; ++itrans) 1911 for (itrans = objs.begin(); itrans != itransend; ++itrans) 1913 1912 { 1914 1913 Renderable *r = itrans->renderable; … … 4197 4196 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 4198 4197 //----------------------------------------------------------------------- 4199 void SceneManager::_renderSceneNode(Camera *cam, SceneNode *node, bool leaveTransparentsInQueue)4198 void SceneManager::_renderSceneNode(Camera *cam, SceneNode *node, const int leavePassesInQueue) 4200 4199 { 4201 4200 // delete previously rendered objects from renderqueue 4202 _deleteRenderedQueueGroups(leave TransparentsInQueue);4201 _deleteRenderedQueueGroups(leavePassesInQueue); 4203 4202 4204 4203 node->_findVisibleObjects(cam, getRenderQueue(), false, mDisplayNodes, false); … … 4206 4205 } 4207 4206 //----------------------------------------------------------------------- 4208 void SceneManager::_deleteRenderedQueueGroups( bool leaveTransparentsInQueue)4207 void SceneManager::_deleteRenderedQueueGroups(const int leavePassesInQueue) 4209 4208 { 4210 4209 RenderQueue::QueueGroupIterator queueIt = getRenderQueue()->_getQueueGroupIterator(); … … 4218 4217 if (isRenderQueueToBeProcessed(qId)) 4219 4218 { 4220 if (leaveTransparentsInQueue) 4221 { 4222 pGroup->clearSolids(); 4223 } 4224 else 4225 { 4226 pGroup->clear(); 4227 } 4219 /*if (leaveTransparentsInQueue) 4220 { pGroup->clearSolids(); } else 4221 { pGroup->clear(); }*/ 4222 pGroup->clear(leavePassesInQueue); 4228 4223 } 4229 4224 } … … 4245 4240 }*/ 4246 4241 //----------------------------------------------------------------------- 4247 void SceneManager::_renderMovableObject(MovableObject *mov, const bool leaveTransparentsInQueue)4242 void SceneManager::_renderMovableObject(MovableObject *mov, const int leavePassesInQueue) 4248 4243 { 4249 4244 // delete previously rendered objects from renderqueue 4250 _deleteRenderedQueueGroups(leave TransparentsInQueue);4245 _deleteRenderedQueueGroups(leavePassesInQueue); 4251 4246 4252 4247 mov->_updateRenderQueue(getRenderQueue()); -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreOctreeSceneManager.h
r115 r139 112 112 @param octree the octant to be rendered (without children) 113 113 @param onlyShadowCasters if only shadow casters are rendered 114 @param leaveTransparentsInQueue if transparemtshould be left in queue for later processing114 @param passes if passes should be left in queue for later processing 115 115 */ 116 void _renderOctant(Camera* cam, Octree *octree, bool onlyShadowCasters, bool leaveTransparentsInQueue = false); 116 void _renderOctant(Camera* cam, Octree *octree, bool onlyShadowCasters, 117 const int leavePassesInQueue = 0); 117 118 118 119 /** Returns stored list of boxes */ -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp
r135 r139 36 36 #include <OgreOctree.h> 37 37 #include <OgreOctreeNode.h> 38 #include <OgreLogManager.h> 38 39 39 40 namespace Ogre … … 109 110 mDepth = 0; 110 111 112 _updateBounds(); 111 113 #endif //GTP_VISIBILITY_MODIFIED_OGRE 112 114 mNumNodes = 0; … … 175 177 //mWireBoundingBox->setupBoundingBox(mBox); 176 178 mWireBoundingBox->setupBoundingBox(mWorldAABB); 179 177 180 return mWireBoundingBox; 178 181 } … … 229 232 // Reset bounds first 230 233 mWorldAABB.setNull(); 231 234 232 235 // Update bounds from own attached objects 233 236 NodeList::iterator it, it_end; … … 247 250 for (int k = 0; k < 2; ++k) 248 251 { 249 if (mChildren[i][j][k] != 0)252 if (mChildren[i][j][k]) 250 253 { 251 254 mWorldAABB.merge(mChildren[i][j][k]->_getWorldAABB()); … … 254 257 } 255 258 } 259 // HACK: clamp to bounds 260 AxisAlignedBox box; 261 _getCullBounds(&box); 262 mWorldAABB = mWorldAABB.intersection(box); 263 264 //std::stringstream d; d << "updating box: " << mWorldAABB << ", depth: " << mDepth << "null: " << mBox.isNull(); 265 //LogManager::getSingleton().logMessage(d.str()); 266 256 267 // recursively update parent bounds 257 268 if (mParent) -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp
r135 r139 1176 1176 //----------------------------------------------------------------------- 1177 1177 void OctreeSceneManager::_renderOctant(Camera *cam, Octree *octant, bool onlyShadowCasters, 1178 bool leaveTransparentsInQueue)//, bool useZPassQueue)1178 const int leavePassesInQueue) 1179 1179 { 1180 1180 // delete previously rendered objects from the render queue 1181 _deleteRenderedQueueGroups(leave TransparentsInQueue);1181 _deleteRenderedQueueGroups(leavePassesInQueue); 1182 1182 1183 1183 //Add stuff to be rendered; -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreTerrainRenderable.cpp
r132 r139 388 388 if (mLastNextLevel != nextLevel) 389 389 { 390 //LogManager::getSingleton().logMessage("vbuffer binding"); 391 if (nextLevel > 0) 392 { 393 //LogManager::getSingleton().logMessage("level > 0"); 394 mTerrain->vertexBufferBinding->setBinding(DELTA_BINDING, 390 if (nextLevel > 0) 391 { 392 mTerrain->vertexBufferBinding->setBinding(DELTA_BINDING, 395 393 mDeltaBuffers[nextLevel - 1]); 396 394 } 397 395 else 398 { 399 //LogManager::getSingleton().logMessage("level <= 0 (dummy b)"); 396 { 400 397 // bind dummy (incase bindings checked) 401 398 mTerrain->vertexBufferBinding->setBinding(DELTA_BINDING, … … 406 403 407 404 } 408 //else LogManager::getSingleton().logMessage("no lod morph");409 /*std::stringstream d;410 d << "terrain: " << this->getName() << ", notify camera: " << cam->getName() << ", pos: " << StringConverter::toString(cam->getDerivedPosition()) <<411 ", distance: " << StringConverter::toString(L) << ", lod level: " << mLastNextLevel412 << ", render level: " << getRenderLevel() << ", morph factor: " << mLODMorphFactor;413 LogManager::getSingleton().logMessage(d.str());*/414 415 405 } 416 406 //-----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.