Changeset 1911


Ignore:
Timestamp:
12/19/06 11:09:01 (17 years ago)
Author:
mattausch
Message:

added support for pvs correction (warning: does not yet compile)

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1909 r1911  
    621621        BvhLeaf *leaf = splitCandidate.mParentData.mNode; 
    622622 
     623        if (USE_AVGRAYCONTRI) 
     624        { 
     625                // this leaf is a pvs entry in all the view cells 
     626                // that see one of the objects. 
     627                const int pvs = CountViewCells(leaf->mObjects); 
     628                //const int pvs = (int)leaf->mObjects.size(); 
     629         
     630                // avg contribution of a ray to a pvs 
     631                const float avgRayContri =  
     632                        AvgRayContribution(pvs, splitCandidate.mParentData.mNumRays); 
     633 
     634                // high avg ray contri, the result is influenced by undersampling 
     635                splitCandidate.SetAvgRayContri(avgRayContri); 
     636        } 
     637 
    623638        const float oldProp = EvalViewCellsVolume(leaf->mObjects); 
    624639        const float oldRenderCost = EvalRenderCost(leaf->mObjects); 
    625                  
     640 
    626641        // compute global decrease in render cost 
    627642        const float newRenderCost = EvalRenderCost(splitCandidate.mFrontObjects) + 
     
    645660                                                                  renderCostDecr, 
    646661                                                                  oldRenderCost); 
    647          
    648         if (USE_AVGRAYCONTRI) 
    649         { 
    650                 // this leaf is a pvs entry in all the view cells 
    651                 // that see one of the objects. 
    652                 const int pvs = CountViewCells(leaf->mObjects); 
    653                 //const int pvs = (int)leaf->mObjects.size(); 
    654          
    655                 // avg contribution of a ray to a pvs 
    656                 const float avgRayContri =  
    657                         AvgRayContribution(pvs, splitCandidate.mParentData.mNumRays); 
    658  
    659                 // high avg ray contri, the result is influenced by undersampling 
    660                 // => decrease priority 
    661                 if (0 && (avgRayContri > mHierarchyManager->mMaxAvgRayContri)) 
    662                 { 
    663                         const float factor = 1.0f + avgRayContri - mHierarchyManager->mMaxAvgRayContri; 
    664                         priority /= factor; 
    665                 } 
    666  
    667                 //splitCandidate.SetAvgRayContri(avgRayContri); 
    668         } 
    669662 
    670663        // compute global decrease in render cost 
     
    17061699        //////////////// 
    17071700        //-- surface area heuristics 
     1701 
    17081702        if (leaf->mObjects.empty()) 
    17091703                return 0.0f; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1904 r1911  
    734734 
    735735 
     736float HierarchyManager::EvalPvsCorrectionFactor(const float childPvs,  
     737                                                                                                const float totalPvs,  
     738                                                                                                const float avgRayContri) const 
     739{ 
     740        if (!childPvs || 
     741                // assume pvs sampled sufficiently => take child pvs 
     742                (avgRayContri < mMinAvgRayContri)) 
     743                return 1.0f; 
     744 
     745        // assume pvs not sampled sufficiently => take total pvs 
     746        if (avgRayContri > mMaxAvgRayContri) 
     747                return totalPvs / childPvs; 
     748 
     749        const float factor =  
     750                        (mMaxAvgRayContri - avgRayContri) /  
     751                        (mMaxAvgRayContri - mMinAvgRayContri); 
     752 
     753        const float newPvs = factor * childPvs + (1.0f - factor) * totalPvs;     
     754         
     755        return newPvs / childPvs; 
     756} 
     757 
     758 
    736759bool HierarchyManager::ApplySubdivisionCandidate(SubdivisionCandidate *sc,  
    737760                                                                                                 SplitQueue &splitQueue, 
     
    780803        // high avg ray contri, the result is influenced by undersampling 
    781804        // => decrease priority 
    782         if (USE_AVGRAYCONTRI && (sc->GetAvgRayContribution() > mMaxAvgRayContri)) 
     805        if (0 && USE_AVGRAYCONTRI && (sc->GetAvgRayContribution() > mMaxAvgRayContri)) 
    783806        { 
    784807                const float factor = 1.0f + sc->GetAvgRayContribution() - mMaxAvgRayContri; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1899 r1911  
    4646#define COUNT_ORIGIN_OBJECTS 1 
    4747#define USE_AVGRAYCONTRI 1 
     48 
     49 
    4850/** View space / object space hierarchy statistics. 
    4951*/ 
     
    294296        void CreateUniqueObjectIds(); 
    295297 
    296  
    297         float mInitialRenderCost; 
     298        float EvalPvsCorrectionFactor(const float pvsFront,  
     299                                                                  const float totalPvs, 
     300                                                                  const float avgRayContri) const; 
    298301 
    299302 
     
    534537 
    535538 
    536  
    537539protected: 
    538540 
     
    563565        // the original vsp type 
    564566        int mSavedViewSpaceSubdivisionType; 
    565         /// the current subdivision candidate 
    566         //SubdivisionCandidate *mCurrentCandidate; 
    567  
     567         
    568568 
    569569        /////////////////// 
     
    575575        OspTree *mOspTree; 
    576576 
     577        float mInitialRenderCost; 
     578         
     579        float mMaxAvgRayContri; 
     580 
     581        float mMinAvgRayContri; 
     582 
    577583        // quick hack: 
    578584public: 
     
    580586        BvHierarchy *mBvHierarchy; 
    581587         
    582         float mMaxAvgRayContri; 
    583  
    584588protected: 
    585589 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1909 r1911  
    863863        { 
    864864                const int pvs = EvalPvsEntriesSize(*splitCandidate.mParentData.mRays); 
     865 
    865866                const float avgRayContri = (float)pvs /  
    866867                        ((float)splitCandidate.mParentData.mRays->size() + Limits::Small); 
    867  
    868                 // high avg ray contri very, the result is influenced by undersampling 
    869                 // => decrease priority 
    870                 if (0 && (avgRayContri > mHierarchyManager->mMaxAvgRayContri)) 
    871                 { 
    872                         const float factor = 1.0f + avgRayContri - mHierarchyManager->mMaxAvgRayContri; 
    873                         priority /= factor; 
    874                 } 
    875868 
    876869                splitCandidate.SetAvgRayContribution(avgRayContri); 
     
    15271520 
    15281521float VspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 
    1529                                                                           const VspTraversalData &data, 
    1530                                                                           float &normalizedOldRenderCost) const 
     1522                                                                          const VspTraversalData &tData, 
     1523                                                                          float &normalizedOldRenderCost, 
     1524                                                                          const float avgRayContri) const 
    15311525{ 
    15321526        float pvsFront = 0; 
     
    15821576        /////////////////// 
    15831577        //-- evaluate render cost heuristics 
    1584  
     1578#if 0 
    15851579        const float penaltyOld = totalPvs; 
     1580 
    15861581    const float penaltyFront = pvsFront; 
    15871582        const float penaltyBack = pvsBack; 
    1588                          
     1583#else 
     1584        const float penaltyOld = totalPvs * tData.mPvsCorrectionFactor; 
     1585 
     1586        const float frontCorr = mHierarchyManager->EvalPvsCorrectionFactor(pvsFront, penaltyOld, avgRayContri); 
     1587        const float backCorr = mHierarchyManager->EvalPvsCorrectionFactor(pvsBack, penaltyOld, avgRayContri); 
     1588 
     1589        const float penaltyFront = frontCorr; 
     1590        const float penaltyBack = pvsBack * backCorr;; 
     1591#endif 
     1592 
    15891593        const float oldRenderCost = pOverall * penaltyOld; 
    15901594        const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
Note: See TracChangeset for help on using the changeset viewer.