Changeset 150 for trunk/VUT/Ogre/src


Ignore:
Timestamp:
06/27/05 17:22:08 (19 years ago)
Author:
mattausch
Message:

added item buffer functionality

Location:
trunk/VUT/Ogre/src
Files:
2 edited

Legend:

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

    r145 r150  
    3131        //-- Render scene to get conservative visibility and fill depth buffer  
    3232 
    33         // can do const_cast because Camera no changed in renderScene 
     33        // const_cast allowed because camera is not changed in renderScene 
    3434        Camera *pCam = const_cast<Camera *>(&camera);  
    3535 
     36        // disable overlays, reset them later 
    3637        bool overlayEnabled = mViewport->getOverlaysEnabled(); 
    3738        mViewport->setOverlaysEnabled(false); 
     
    3940 
    4041        /*  
    41                 Two query lists: 
    42                 We test two to get exact visibility with regard to the current camera and 
    43                 issue all queries at once to avoid starvation & stalls. 
     42                Two query lists for projected pixels and for visibile pixels: 
     43                We test queries after a rendering pass  
     44                to get exact visibility with regard to the current camera. 
     45                We issue all queries at once to avoid starvation & stalls. 
    4446        */ 
    4547        GtpVisibility::QueryList queryList[2]; 
     
    100102        // this option must be provided by the scene manager 
    101103        pfHierarchyInterface->GetSceneManager()->setOption("DepthWrite", &enableDepthWrite); 
    102          
     104        // reset old overlay status 
    103105        mViewport->setOverlaysEnabled(overlayEnabled); 
    104106 
    105107        //---- collect results 
    106          
    107         std::pair<InfoContainer<GtpVisibility::NodeInfo>::iterator, bool> insertNode; 
    108         std::pair<InfoContainer<GtpVisibility::MeshInfo>::iterator, bool> insertGeom; 
    109  
    110108        GtpVisibility::QueryList::iterator visQueryIt, projQueryIt; 
    111109 
     
    236234        mViewport->setCamera(savedCam); 
    237235 
    238         // --- single out duplicates 
    239  
    240         // before duplicates can be deleted we have to add up visibility 
     236        // --- remove duplicates (happens if an object is on the edge of the viewport) 
     237 
     238        // before duplicates can be deleted we have to add up their visibility 
    241239 
    242240        // --- visible nodes 
     
    261259        } 
    262260         
    263         // now delete duplicates 
     261        // really delete duplicates 
    264262        visibleNodes->erase( std::unique(visibleNodes->begin(),  
    265263                visibleNodes->end(), nodeinfo_eq), visibleNodes->end()); 
     
    286284        } 
    287285 
    288         // now delete duplicates 
     286        // really delete duplicates 
    289287        visibleGeometry->erase(std::unique(visibleGeometry->begin(), visibleGeometry->end(),  
    290288                meshinfo_eq), visibleGeometry->end()); 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r149 r150  
    7878                mItemBufferPass->setDepthWriteEnabled(true); 
    7979                mItemBufferPass->setLightingEnabled(true); 
     80                //mItemBufferPass->setLightingEnabled(false); 
    8081        } 
    8182        else 
     
    8384                mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0); 
    8485        } 
    85         mItemBufferPass->setAmbient(1, 1, 0); 
     86        //mItemBufferPass->setAmbient(1, 1, 0); 
    8687} 
    8788//----------------------------------------------------------------------- 
     
    213214void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    214215{ 
    215         // needs full ambient lighting for item colors to be exact 
    216         //if (mRenderItemBuffer) {setAmbientLight(ColourValue(1,1,1,1));} 
    217          
    218216        //-- show visible scene nodes and octree bounding boxes from last frame 
    219217        if (mShowVisualization) 
     
    244242void VisibilityTerrainSceneManager::_renderVisibleObjects() 
    245243{ 
     244        ColourValue savedAmbient = mAmbientLight; 
     245 
    246246        // visualization or shadow pass: apply standard rendering 
    247247        if (mShowVisualization || (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE &&  
     
    305305                mLeavePassesInQueue = 0; 
    306306                mShadowTechnique = mSavedShadowTechnique; 
    307  
     307                mRenderItemBuffer = false; 
    308308 
    309309                // add visible nodes found by the visibility culling algorithm 
     
    327327 
    328328        getRenderQueue()->clear(); 
     329 
     330        // reset ambient light 
     331        setAmbientLight(savedAmbient); 
    329332        //WriteLog(); // write out stats 
    330333} 
     
    399402        { 
    400403                mEnableDepthWrite = (*static_cast<const bool *>(val)); 
     404                return true; 
     405        } 
     406        if (key == "ItemBuffer") 
     407        { 
     408                mRenderItemBuffer = (*static_cast<const bool *>(val)); 
    401409                return true; 
    402410        } 
     
    531539 
    532540        // ----- TRANSPARENT LOOP: must be handled differently  
    533         // although we don't really     care about transparents for the item buffer 
    534541        // TODO: HOW TO HANDLE OCCLUDED OBJECTS ???? 
    535542        RenderPriorityGroup::TransparentRenderablePassList 
     
    551558{ 
    552559        static LightList nullLightList; 
    553  
    554         Real col = (Real)rend->getId() / (Real)mCurrentEntityId; 
    555  
    556         mItemBufferPass->setAmbient(ColourValue(0, col, 0)); 
    557         //mItemBufferPass->setDiffuse(ColourValue(0, col, 0)); 
    558     //mItemBufferPass->setSpecular(ColourValue(0, col, 0)); 
     560         
     561        int col[4]; 
     562         
     563        col[0] = (rend->getId() >> 16) & 255; 
     564        col[1] = (rend->getId() >> 8) & 255; 
     565        col[2] = rend->getId() & 255; 
     566        col[3] = 255; 
     567 
     568        //mDestRenderSystem->setColour(col[0], col[1], col[2], col[3]); 
    559569     
     570        mItemBufferPass->setAmbient(ColourValue(col[0] / 255.0f, 
     571                                                                                    col[1] / 255.0f,  
     572                                                                                        col[2] / 255.0f, 1)); 
     573 
    560574        // set vertex program of current pass 
    561575        if (pass->hasVertexProgram()) 
     
    581595        //Pass *usedPass = setPass(pass); 
    582596         
    583         std::stringstream d; d << "item buffer id: " << rend->getId() << ", col: " << col; 
    584         LogManager::getSingleton().logMessage(d.str()); 
     597        if (rend->getId() > 0) 
     598        { 
     599                std::stringstream d; d << "item buffer id: " << rend->getId() << ", col: " << col[0] << 
     600                        " " << col[1] << " " << col[2] << " " << col[3]; 
     601                LogManager::getSingleton().logMessage(d.str()); 
     602        } 
    585603 
    586604        // Render a single object, this will set up auto params if required 
    587605        renderSingleObject(rend, usedPass, false, &nullLightList); 
     606 
     607        // reset colour 
     608        //mDestRenderSystem->setColour(255, 255, 255, 255); 
    588609} 
    589610//----------------------------------------------------------------------- 
     
    600621        for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 
    601622        { 
    602                 ent->getSubEntity(i)->setId(mCurrentEntityId ++); 
    603         } 
     623                ent->getSubEntity(i)->setId(mCurrentEntityId); 
     624        } 
     625 
     626        ++ mCurrentEntityId; 
    604627 
    605628        return ent; 
     
    615638 
    616639 
     640        mLeavePassesInQueue = 0; 
     641         
     642        // item buffer needs full ambient lighting to use item colors as unique id 
     643        if (mUseItemBuffer)  
     644        { 
     645                mRenderItemBuffer = true; 
     646                setAmbientLight(ColourValue(1,1,1,1)); 
     647        } 
     648 
     649 
    617650        // set passes which should be stored in render queue  
    618651        // for rendering after hierarchical culling 
    619         mLeavePassesInQueue = 0; 
    620          
     652 
    621653        if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) 
    622654        { 
     
    662694 
    663695        // set depth pass flag before rendering 
    664     mRenderDepthPass = mUseDepthPass; 
    665          
     696        mRenderDepthPass = mUseDepthPass; 
    666697        // set flag for skipping transparents in the hierarchical culling pass 
    667698        mSkipTransparents = mUseDepthPass ||  
Note: See TracChangeset for help on using the changeset viewer.