Changeset 2160


Ignore:
Timestamp:
02/23/07 11:50:31 (17 years ago)
Author:
mattausch
Message:

depth pass now done in findVisibleObjects. This makes it possible to process the objects found in this method, e.g., with the illumination modules

Location:
GTP/trunk/Lib/Vis
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h

    r2145 r2160  
    175175        /** Load a scene. 
    176176        */ 
    177         bool LoadScene(const String &filename, const String &viewCellsFilename); 
     177        bool LoadScene(const String &filename,  
     178                                   const String &viewCellsFilename); 
    178179 
    179180        void loadConfig(DataStreamPtr& stream); 
     181 
     182        void RenderDepthPass(); 
     183 
     184        void _renderScene(Camera* camera, Viewport* vp, bool includeOverlays); 
    180185 
    181186        ////////////////////////////////////////// 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp

    r2145 r2160  
    613613        // set depth fill pass if we currently do not make an aabb occlusion query 
    614614        const bool useDepthPass =  
    615                 (mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery()); 
     615                mUseDepthPass && mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery(); 
    616616 
    617617        const IlluminationRenderStage savedStage = mIlluminationStage;  
    618618         
    619         // set illumination stage to NONE so no shadow material is used  
    620         // for depth pass or for occlusion query 
    621         if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery()) 
    622         { 
    623                 mIlluminationStage = IRS_NONE; 
    624         } 
    625          
    626         // --- set vertex program of current pass in order to set correct depth 
    627         if (mExecuteVertexProgramForAllPasses &&  
    628                 mIsDepthPassPhase &&  
    629                 pass->hasVertexProgram()) 
    630         { 
    631                 // add vertex program of current pass to depth pass 
    632                 mDepthPass->setVertexProgram(pass->getVertexProgramName()); 
    633  
    634                 if (mDepthPass->hasVertexProgram()) 
    635                 { 
    636                         const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 
    637                         // Load this program if not done already 
    638                         if (!prg->isLoaded()) 
    639                                 prg->load(); 
    640                         // Copy params 
    641                         mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 
    642                 } 
    643         } 
    644         else if (mDepthPass->hasVertexProgram()) // reset vertex program 
    645         { 
    646                 mDepthPass->setVertexProgram(""); 
    647         } 
    648          
     619        if (useDepthPass) 
     620        { 
     621                // set illumination stage to NONE so no shadow material is used  
     622                // for depth pass or for occlusion query 
     623                if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery()) 
     624                { 
     625                        mIlluminationStage = IRS_NONE; 
     626                } 
     627         
     628                //--- set vertex program of current pass in order to set correct depth 
     629                if (mExecuteVertexProgramForAllPasses &&  
     630                        mIsDepthPassPhase &&  
     631                        pass->hasVertexProgram()) 
     632                { 
     633                        // add vertex program of current pass to depth pass 
     634                        mDepthPass->setVertexProgram(pass->getVertexProgramName()); 
     635 
     636                        if (mDepthPass->hasVertexProgram()) 
     637                        { 
     638                                const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 
     639                                // Load this program if not done already 
     640                                if (!prg->isLoaded()) 
     641                                        prg->load(); 
     642                                // Copy params 
     643                                mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 
     644                        } 
     645                } 
     646                else if (mDepthPass->hasVertexProgram())  
     647                {       // reset vertex program 
     648                        mDepthPass->setVertexProgram(""); 
     649                } 
     650        } 
     651 
    649652        const Pass *usedPass = useDepthPass ? mDepthPass : pass; 
    650653 
     
    682685                ////////////// 
    683686                //-- show visible scene nodes and octree bounding boxes from last frame 
     687 
    684688                PrepareVisualization(cam); 
    685         } 
    686         else  
    687         {        
    688                 // hierarchical culling interleaves identification  
    689                 // and rendering of objects in _renderVisibibleObjects 
    690  
    691                 // for the shadow pass we use only standard rendering 
    692                 // because shadows have low occlusion anyway 
    693                 if (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE &&  
    694                         mIlluminationStage == IRS_RENDER_TO_TEXTURE) 
    695                 { 
    696                         OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
    697                 } 
    698  
    699                 // only shadow casters will be rendered in shadow texture pass 
    700                 if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
    701  
    702                 /////////// 
    703                 //-- set visibility according to pvs of current view cell 
    704  
    705                 UpdatePvs(cam); 
    706  
    707                 if (mNormalExecution) 
    708                 { 
    709                         OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
    710                         //return; 
    711                 } 
    712         } 
    713                  
     689                 
     690                // lists only used for visualization 
     691                mVisible.clear(); 
     692                mBoxes.clear(); 
     693 
     694                return; 
     695        } 
     696         
    714697        // lists only used for visualization 
    715698        mVisible.clear(); 
    716699        mBoxes.clear(); 
     700 
     701        /////////// 
     702        //-- set visibility according to pvs of current view cell 
     703 
     704        UpdatePvs(cam); 
     705 
     706        // standard rendering in first pass 
     707        if (!mNormalExecution && mUseDepthPass) 
     708        { 
     709                RenderDepthPass(); 
     710        } 
     711        else 
     712        { 
     713                // hierarchical culling interleaves identification  
     714                // and rendering of objects in _renderVisibibleObjects 
     715 
     716                // for the shadow pass we use only standard rendering 
     717                // because shadows have low occlusion anyway 
     718                if ((mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE &&  
     719                        mIlluminationStage == IRS_RENDER_TO_TEXTURE) || 
     720                        mNormalExecution) 
     721                { 
     722                        OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     723                } 
     724 
     725                // only shadow casters will be rendered in shadow texture pass 
     726                //if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
     727        } 
    717728} 
    718729//----------------------------------------------------------------------- 
    719730void OcclusionCullingSceneManager::_renderVisibleObjects() 
    720731{ 
    721         const bool flushQueue = mDeleteQueueAfterRendering && ((mCurrentFrame % mFlushRate) == 0); 
     732        const bool flushQueue =  
     733                mDeleteQueueAfterRendering && ((mCurrentFrame % mFlushRate) == 0); 
    722734        ++ mCurrentFrame; 
    723735 
     
    730742        } 
    731743 
    732         InitDepthPass();          // create material for depth pass 
    733744        InitItemBufferPass(); // create material for item buffer pass 
    734745 
     
    740751        //-- (e.g., the visualization mode, the shadow pass) 
    741752 
    742         if (mShowVisualization || 
     753        if (mUseDepthPass || mShowVisualization || 
    743754            (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE &&  
    744755             mIlluminationStage == IRS_RENDER_TO_TEXTURE)) 
     
    795806                addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 
    796807         
    797                 // exclude this queues from hierarchical rendering 
     808                // exclude these queues from hierarchical rendering 
    798809                setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
    799810 
     
    819830 
    820831                ///////////// 
    821                 //-- reset parameters needed for special rendering 
    822                  
    823                 mIsDepthPassPhase = false; 
     832                //-- reset parameters needed during hierarchical rendering 
     833                 
    824834                mIsItemBufferPhase = false; 
    825835                mSkipTransparents = false; 
     
    827837                 
    828838                mLeavePassesInQueue = 0; 
    829                  
    830                  // the shaded geometry is rendered in a second pass 
    831                 if (mUseDepthPass) 
    832                 { 
    833                         // add visible nodes found by the visibility culling algorithm 
    834                         NodeList::const_iterator it, it_end = mVisible.end(); 
    835  
    836                         //getRenderQueue()->clear(); 
    837                         for (it = mVisible.begin(); it != it_end; ++ it) 
    838                         { 
    839                                 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 
    840                         } 
    841                 } 
    842                  
     839                         
    843840                ///////////// 
    844841                //-- now we can render all remaining queue objects 
     
    868865        if (mNormalExecution) 
    869866        { 
    870                 OctreeSceneManager::_updateSceneGraph(cam); 
     867                TerrainSceneManager::_updateSceneGraph(cam); 
    871868                return; 
    872869        } 
     
    13261323        mIsDepthPassPhase = mUseDepthPass; 
    13271324 
    1328         mIsHierarchicalCulling = true; // during hierarchical culling 
     1325        // indicates that we use hierarchical culling from now on 
     1326        mIsHierarchicalCulling = true;  
    13291327 
    13301328        // item buffer needs full ambient lighting to use item colors as unique id 
     
    13421340        mLeavePassesInQueue = 0; 
    13431341 
    1344         // if we have the depth pass or use an item buffer, no passes are left in the queue 
     1342        // if we have the depth pass or use an item buffer, we leave no passes in the queue 
    13451343        if (1 && !mUseDepthPass && !mUseItemBuffer) 
    13461344        { 
     
    18191817        return false; 
    18201818} 
     1819 
     1820 
     1821#if 0 
     1822void OcclusionCullingSceneManager::RenderDepthPass() 
     1823{ 
     1824        //////////////////// 
     1825        //-- hierarchical culling 
     1826 
     1827        // exclude these queues from hierarchical rendering 
     1828        clearSpecialCaseRenderQueues(); 
     1829        addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 
     1830        addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 
     1831        addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 
     1832        addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 
     1833        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
     1834 
     1835        // set all necessary parameters for  
     1836        // hierarchical visibility culling and rendering 
     1837        InitVisibilityCulling(mCameraInProgress); 
     1838 
     1839 
     1840        /**  
     1841        * the hierarchical culling algorithm 
     1842        * for depth pass: we just find objects and update depth buffer 
     1843        * for "delayed" rendering: we render some passes afterwards 
     1844        * e.g., transparents, because they need front-to-back sorting 
     1845        **/ 
     1846                 
     1847        mVisibilityManager->ApplyVisibilityCulling(); 
     1848 
     1849        // delete remaining renderables from queue: 
     1850        // all which are not in mLeavePassesInQueue) 
     1851        _deleteRenderedQueueGroups(mLeavePassesInQueue); 
     1852 
     1853        ///////////// 
     1854        //-- reset parameters needed for special rendering 
     1855                 
     1856        mIsDepthPassPhase = false; 
     1857        mIsItemBufferPhase = false; 
     1858        mSkipTransparents = false; 
     1859        mIsHierarchicalCulling = false; 
     1860                 
     1861        mLeavePassesInQueue = 0; 
     1862                 
     1863        ///////////// 
     1864        //-- now we can render all remaining queue objects 
     1865        //-- used for depth pass, transparents, overlay 
     1866    clearSpecialCaseRenderQueues(); 
     1867 
     1868        // the shaded geometry is rendered in a second pass 
     1869        // add visible nodes found by the visibility culling algorithm 
     1870        NodeList::const_iterator it, it_end = mVisible.end(); 
     1871 
     1872        if(1)  
     1873        for (it = mVisible.begin(); it != it_end; ++ it) 
     1874        { 
     1875                (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 
     1876        } 
     1877} 
     1878#endif 
     1879void OcclusionCullingSceneManager::RenderDepthPass() 
     1880{ 
     1881        InitDepthPass(); // create material for depth pass 
     1882 
     1883        //////////////////// 
     1884        //-- hierarchical culling 
     1885 
     1886        // set all necessary parameters for  
     1887        // hierarchical visibility culling and rendering 
     1888        InitVisibilityCulling(mCameraInProgress); 
     1889 
     1890 
     1891        /**  
     1892        * the hierarchical culling algorithm 
     1893        * for depth pass: we just find objects and update depth buffer 
     1894        * for "delayed" rendering: we render some passes afterwards 
     1895        * e.g., transparents, because they need front-to-back sorting 
     1896        **/ 
     1897                 
     1898        mVisibilityManager->ApplyVisibilityCulling(); 
     1899 
     1900        // delete remaining renderables from queue 
     1901        //_deleteRenderedQueueGroups(); 
     1902        getRenderQueue()->clear(); 
     1903 
     1904        ///////////// 
     1905        //-- reset parameters needed for special rendering 
     1906                 
     1907        mIsDepthPassPhase = false; 
     1908        mIsItemBufferPhase = false; 
     1909        mSkipTransparents = false; 
     1910        mIsHierarchicalCulling = false; 
     1911        mLeavePassesInQueue = 0; 
     1912                 
     1913        // the shaded geometry is rendered in a second pass 
     1914        // add visible nodes found by the visibility culling algorithm 
     1915        NodeList::const_iterator it, it_end = mVisible.end(); 
     1916 
     1917        if(1)  
     1918        for (it = mVisible.begin(); it != it_end; ++ it) 
     1919        { 
     1920                (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 
     1921        } 
     1922} 
    18211923//----------------------------------------------------------------------- 
    18221924bool OcclusionCullingSceneManager::LoadSceneObj(const String &filename, 
     
    18411943        return true; 
    18421944} 
     1945 
     1946//----------------------------------------------------------------------- 
     1947void OcclusionCullingSceneManager::_renderScene(Camera* camera, Viewport* vp, bool includeOverlays) 
     1948{ 
     1949    Root::getSingleton()._setCurrentSceneManager(this); 
     1950        mActiveQueuedRenderableVisitor->targetSceneMgr = this; 
     1951 
     1952    if (isShadowTechniqueInUse()) 
     1953    { 
     1954        // Prepare shadow materials 
     1955        initShadowVolumeMaterials(); 
     1956    } 
     1957 
     1958    // Perform a quick pre-check to see whether we should override far distance 
     1959    // When using stencil volumes we have to use infinite far distance 
     1960    // to prevent dark caps getting clipped 
     1961    if (isShadowTechniqueStencilBased() &&  
     1962        camera->getProjectionType() == PT_PERSPECTIVE && 
     1963        camera->getFarClipDistance() != 0 &&  
     1964        mDestRenderSystem->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE) &&  
     1965        mShadowUseInfiniteFarPlane) 
     1966    { 
     1967        // infinite far distance 
     1968        camera->setFarClipDistance(0); 
     1969    } 
     1970 
     1971    mCameraInProgress = camera; 
     1972 
     1973 
     1974    // Update controllers  
     1975    ControllerManager::getSingleton().updateAllControllers(); 
     1976 
     1977    // Update the scene, only do this once per frame 
     1978    unsigned long thisFrameNumber = Root::getSingleton().getCurrentFrameNumber(); 
     1979    if (thisFrameNumber != mLastFrameNumber) 
     1980    { 
     1981        // Update animations 
     1982        _applySceneAnimations(); 
     1983        mLastFrameNumber = thisFrameNumber; 
     1984    } 
     1985 
     1986    // Update scene graph for this camera (can happen multiple times per frame) 
     1987    _updateSceneGraph(camera); 
     1988 
     1989    // Auto-track nodes 
     1990    AutoTrackingSceneNodes::iterator atsni, atsniend; 
     1991    atsniend = mAutoTrackingSceneNodes.end(); 
     1992    for (atsni = mAutoTrackingSceneNodes.begin(); atsni != atsniend; ++atsni) 
     1993    { 
     1994        (*atsni)->_autoTrack(); 
     1995    } 
     1996    // Auto-track camera if required 
     1997    camera->_autoTrack(); 
     1998 
     1999 
     2000    // Are we using any shadows at all? 
     2001    if (isShadowTechniqueInUse() &&  
     2002        mIlluminationStage != IRS_RENDER_TO_TEXTURE && 
     2003                vp->getShadowsEnabled() && 
     2004                mFindVisibleObjects) 
     2005    { 
     2006        // Locate any lights which could be affecting the frustum 
     2007        findLightsAffectingFrustum(camera); 
     2008        if (isShadowTechniqueTextureBased()) 
     2009        { 
     2010            // ******* 
     2011            // WARNING 
     2012            // ******* 
     2013            // This call will result in re-entrant calls to this method 
     2014            // therefore anything which comes before this is NOT  
     2015            // guaranteed persistent. Make sure that anything which  
     2016            // MUST be specific to this camera / target is done  
     2017            // AFTER THIS POINT 
     2018            prepareShadowTextures(camera, vp); 
     2019            // reset the cameras because of the re-entrant call 
     2020            mCameraInProgress = camera; 
     2021        } 
     2022    } 
     2023 
     2024    // Invert vertex winding? 
     2025    if (camera->isReflected()) 
     2026    { 
     2027        mDestRenderSystem->setInvertVertexWinding(true); 
     2028    } 
     2029    else 
     2030    { 
     2031        mDestRenderSystem->setInvertVertexWinding(false); 
     2032    } 
     2033 
     2034    // Tell params about viewport 
     2035    mAutoParamDataSource.setCurrentViewport(vp); 
     2036    // Set the viewport 
     2037    setViewport(vp); 
     2038 
     2039    // Tell params about camera 
     2040    mAutoParamDataSource.setCurrentCamera(camera); 
     2041    // Set autoparams for finite dir light extrusion 
     2042    mAutoParamDataSource.setShadowDirLightExtrusionDistance(mShadowDirLightExtrudeDist); 
     2043 
     2044    // Tell params about current ambient light 
     2045    mAutoParamDataSource.setAmbientLightColour(mAmbientLight); 
     2046        // Tell rendersystem 
     2047        mDestRenderSystem->setAmbientLight(mAmbientLight.r, mAmbientLight.g, mAmbientLight.b); 
     2048 
     2049    // Tell params about render target 
     2050    mAutoParamDataSource.setCurrentRenderTarget(vp->getTarget()); 
     2051 
     2052 
     2053    // Set camera window clipping planes (if any) 
     2054    if (mDestRenderSystem->getCapabilities()->hasCapability(RSC_USER_CLIP_PLANES)) 
     2055    { 
     2056        if (camera->isWindowSet())   
     2057        { 
     2058            const std::vector<Plane>& planeList =  
     2059                camera->getWindowPlanes(); 
     2060            for (ushort i = 0; i < 4; ++i) 
     2061            { 
     2062                mDestRenderSystem->enableClipPlane(i, true); 
     2063                mDestRenderSystem->setClipPlane(i, planeList[i]); 
     2064            } 
     2065        } 
     2066        else 
     2067        { 
     2068            for (ushort i = 0; i < 4; ++i) 
     2069            { 
     2070                mDestRenderSystem->enableClipPlane(i, false); 
     2071            } 
     2072        } 
     2073    } 
     2074 
     2075        // Prepare render queue for receiving new objects 
     2076        prepareRenderQueue(); 
     2077 
     2078        mDestRenderSystem->_beginGeometryCount(); 
     2079    // Begin the frame 
     2080    mDestRenderSystem->_beginFrame(); 
     2081 
     2082    // Set rasterisation mode 
     2083    mDestRenderSystem->_setPolygonMode(camera->getPolygonMode()); 
     2084 
     2085        // Set initial camera state 
     2086        mDestRenderSystem->_setProjectionMatrix(mCameraInProgress->getProjectionMatrixRS()); 
     2087        mDestRenderSystem->_setViewMatrix(mCameraInProgress->getViewMatrix(true)); 
     2088 
     2089 
     2090    if (mFindVisibleObjects) 
     2091    { 
     2092        // Parse the scene and tag visibles 
     2093        _findVisibleObjects(camera,  
     2094            mIlluminationStage == IRS_RENDER_TO_TEXTURE? true : false); 
     2095    } 
     2096    // Add overlays, if viewport deems it 
     2097    if (vp->getOverlaysEnabled() && mIlluminationStage != IRS_RENDER_TO_TEXTURE) 
     2098    { 
     2099        OverlayManager::getSingleton()._queueOverlaysForRendering(camera, getRenderQueue(), vp); 
     2100    } 
     2101    // Queue skies, if viewport seems it 
     2102    if (vp->getSkiesEnabled() && mFindVisibleObjects && mIlluminationStage != IRS_RENDER_TO_TEXTURE) 
     2103    { 
     2104        _queueSkiesForRendering(camera); 
     2105    } 
     2106 
     2107  
     2108    // Render scene content  
     2109    _renderVisibleObjects(); 
     2110 
     2111    // End frame 
     2112    mDestRenderSystem->_endFrame(); 
     2113 
     2114    // Notify camera or vis faces 
     2115    camera->_notifyRenderedFaces(mDestRenderSystem->_getFaceCount()); 
     2116} 
     2117 
    18432118//----------------------------------------------------------------------- 
    18442119const String OcclusionCullingSceneManagerFactory::FACTORY_TYPE_NAME = "OcclusionCullingSceneManager"; 
     
    18622137        mTerrainPageSources.push_back(ps); 
    18632138        tsm->registerPageSource("Heightmap", ps); 
    1864 LogManager::getSingleton().logMessage("here4"); 
     2139 
    18652140        return tsm; 
    18662141} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2146 r2160  
    2121                                Optimization="0" 
    2222                                AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;Timer" 
    23                                 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_BIT_PVS" 
     23                                PreprocessorDefinitions="WIN32;_DEBUG;_LIB" 
    2424                                MinimalRebuild="TRUE" 
    2525                                BasicRuntimeChecks="3" 
Note: See TracChangeset for help on using the changeset viewer.