Ignore:
Timestamp:
05/30/05 03:20:23 (19 years ago)
Author:
mattausch
Message:

added depth pass algorithm + delayed transparent object rendering (so depth ordering is right)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r114 r115  
    1414:  
    1515mVisibilityManager(visManager),  
    16 mUseVisibilityCulling(true), 
     16mUseDepthPass(false), 
    1717mShowVisualization(false), 
    1818mRenderNodesForViz(false), 
    1919mVisualizeCulledNodes(false), 
    20 mRenderTransparentObjects(false) 
     20mSkipTransparents(false), 
     21mDelayRenderTransparents(true) 
    2122{ 
    2223        mHierarchyInterface =  
     
    2930        // TODO: find reasonable value for max depth 
    3031        mMaxDepth = 50; 
     32 
     33        CreateDepthPass(); 
     34} 
     35//----------------------------------------------------------------------- 
     36void VisibilityOctreeSceneManager::CreateDepthPass() 
     37{ 
     38        MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass"); 
     39 
     40        if (depthMat.isNull()) 
     41    { 
     42                // Init 
     43                depthMat = MaterialManager::getSingleton().create( 
     44                "Visibility/DepthPass", 
     45                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
     46 
     47                depthMat->createTechnique()->createPass(); 
     48        mDepthPass = depthMat->getTechnique(0)->getPass(0); 
     49                mDepthPass->setColourWriteEnabled(false); 
     50                mDepthPass->setDepthWriteEnabled(true); 
     51                mDepthPass->setLightingEnabled(false); 
     52        } 
     53        else 
     54        { 
     55                mDepthPass = depthMat->getTechnique(0)->getPass(0); 
     56        } 
    3157} 
    3258//----------------------------------------------------------------------- 
     
    3864void VisibilityOctreeSceneManager::_renderVisibleObjects() 
    3965{ 
    40         // two cameras (one for culling, one for rendering) 
    41         mHierarchyInterface->InitFrame(mOctree, mCameraInProgress,  
    42                                                         mCullCamera ? getCamera("CullCamera") : NULL); 
    43  
    44         if (!mShowVisualization) 
     66                if (!mShowVisualization) 
    4567        { 
    4668                // two cameras (one for culling, one for rendering) 
    4769                mHierarchyInterface->InitFrame(mOctree, mCameraInProgress,  
    48                                                                 mCullCamera ? getCamera("CullCamera") : NULL); 
     70                                                                mCullCamera ? getCamera("CullCamera") : NULL, mDelayRenderTransparents); 
    4971 
    5072                // call initframe to reset culling manager stats 
    5173                mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 
    5274        } 
     75         
     76        // standard terrain scenemanager rendering without hierarchical culling 
     77        if (!mUseDepthPass || mShowVisualization) 
     78        {        
     79                OctreeSceneManager::_renderVisibleObjects(); 
     80         
     81                return; 
     82        }  
    5383         
    5484        //-- hierarchical culling 
    5585        // the objects of different layers (e.g., background, scene,  
    5686        // overlay) must be identified and rendered one after another 
     87 
     88        mSkipTransparents = false; 
    5789 
    5890        //-- render background 
     
    6597 
    6698#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    67         _deleteRenderedQueueGroups(); 
     99        _deleteRenderedQueueGroups(false); 
    68100#endif 
    69101 
     
    72104        addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 
    73105        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
    74  
     106         
     107        // render only solids in hierarchical algorithm.  
     108        // Transparents need sorting, thus we render them afterwards 
     109        mSkipTransparents = mDelayRenderTransparents; 
    75110 
    76111        /**  
    77112        * the hierarchical culling algorithm 
    78113        **/ 
     114         
    79115        mVisibilityManager->ApplyVisibilityCulling(); 
    80  
    81  
    82 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    83         _deleteRenderedQueueGroups(); 
    84 #endif 
    85  
    86         //-- render overlay 
     116         
     117        //-- now we can savely render all remaining objects, e.g., transparents, overlay 
     118        mSkipTransparents = false; 
     119 
    87120        clearSpecialCaseRenderQueues(); 
    88121        SceneManager::_renderVisibleObjects(); 
     
    99132        // we interleave identification and rendering of objects  
    100133        // in _renderVisibibleObjects 
    101         if (!mUseVisibilityCulling) 
     134        if (!mUseDepthPass) 
    102135        { 
    103136                OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     
    123156                if (mRenderNodesForViz || mRenderNodesContentForViz) 
    124157                { 
    125                         // change node material so it is better suited for visualization 
    126                 /*      MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 
     158                /*      // change node material so it is better suited for visualization 
     159                        MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 
    127160                        nodeMat->setAmbient(1, 1, 0); 
    128161                        nodeMat->setLightingEnabled(true); 
     
    164197bool VisibilityOctreeSceneManager::setOption(const String & key, const void * val) 
    165198{ 
    166         if (key == "UseVisibilityCulling") 
    167         { 
    168                 mUseVisibilityCulling = (*static_cast<const bool *>(val)); 
     199        if (key == "UseDepthPass") 
     200        { 
     201                mUseDepthPass = (*static_cast<const bool *>(val)); 
    169202                return true; 
    170203        } 
     
    199232                return true; 
    200233        } 
    201  
     234        if (key == "DelayRenderTransparents") 
     235        { 
     236                mDelayRenderTransparents = (*static_cast<const bool *>(val)); 
     237                return true; 
     238        } 
    202239        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
    203240                setOption(key, val) || OctreeSceneManager::setOption(key, val); 
     
    240277            bool doLightIteration, const LightList* manualLightList) 
    241278{ 
    242         if (mRenderTransparentObjects) 
     279        if (!mSkipTransparents) 
    243280        { 
    244281                OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList); 
Note: See TracChangeset for help on using the changeset viewer.