Ignore:
Timestamp:
12/14/06 23:02:53 (18 years ago)
Author:
mattausch
Message:

added avg ray contrib

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

Legend:

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

    r1893 r1895  
    587587static float AvgRayContribution(const int pvs, const int nRays) 
    588588{ 
    589         return (float)pvs / (float)nRays; 
     589        return (float)pvs / ((float)nRays + Limits::Small); 
    590590} 
    591591 
     
    646646                                                                  renderCostDecr); 
    647647         
    648         // avg ray contri: this leaf is a pvs entry in all the view cells 
    649         // that see one of the objects. 
    650         const int numViewCells = CountViewCells(leaf->mObjects); 
    651          
    652         const float avgRayContri =  
    653                 AvgRayContribution(numViewCells, splitCandidate.mParentData.mNumRays); 
    654  
    655         cout << "avgRayContri: " << avgRayContri << endl; 
    656  
    657         // avg ray contri very high. i.e., the result is influenced by undersampling 
    658         // => decrease priority 
    659         if (avgRayContri > 99925) 
    660         { 
    661                 priority /= avgRayContri; 
     648        if (0) 
     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                Debug << "bvh avgRayContri: " << avgRayContri << " #pvs: " << pvs << " #rays: " << splitCandidate.mParentData.mNumRays << endl; 
     660                cout << "bvh avgRayContri: " << avgRayContri << endl; 
     661 
     662                // high avg ray contri, the result is influenced by undersampling 
     663                // => decrease priority 
     664                if (0 && (avgRayContri > mHierarchyManager->mMaxAvgRayContri)) 
     665                { 
     666                        const float factor = 1.0f + avgRayContri - mHierarchyManager->mMaxAvgRayContri; 
     667                        cout << "here5 " << factor << endl; 
     668 
     669                        priority /= factor; 
     670                } 
     671 
     672                //splitCandidate.SetAvgRayContri(avgRayContri); 
    662673        } 
    663674 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1887 r1895  
    26452645                                        "true"); 
    26462646 
     2647        RegisterOption("Hierarchy.Construction.maxAvgRayContri", 
     2648                                        optFloat, 
     2649                                        "hierarchy_construction_max_avg_raycontri=", 
     2650                                        "99999.0"); 
     2651         
    26472652        ///////////////////////////////////////////////////////////////// 
     2653 
    26482654} 
    26492655 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1893 r1895  
    3131#define STUPID_METHOD 0 
    3232 
     33 
     34 
    3335/*******************************************************************/ 
    3436/*              class HierarchyManager implementation              */ 
     
    151153                "Hierarchy.Construction.maxRepairs", mMaxRepairs); 
    152154 
    153         // compare to bytes 
     155        Environment::GetSingleton()->GetFloatValue( 
     156                "Hierarchy.Construction.maxAvgRayContri", mMaxAvgRayContri); 
     157 
     158        // for comparing it with byte - value 
    154159        mTermMaxMemory *= (1024.0f * 1024.0f); 
    155160 
     
    168173        Debug << "max steps of same kind: " << mMaxStepsOfSameType << endl; 
    169174        Debug << "max repairs: " << mMaxRepairs << endl; 
     175        Debug << "max avg ray contribution: " << mMaxAvgRayContri << endl; 
     176 
    170177 
    171178        switch (mConstructionType) 
     
    769776 
    770777        // memory size in byte 
    771         mHierarchyStats.mMemory += (float)ObjectPvs::GetEntrySizeByte() * pvsEntriesIncr; 
     778        float mem = (float)ObjectPvs::GetEntrySizeByte() * pvsEntriesIncr; 
     779 
     780        // high avg ray contri, the result is influenced by undersampling 
     781        // => decrease priority 
     782        if (0 && (sc->GetAvgRayContribution() > mMaxAvgRayContri)) 
     783        { 
     784                const float factor = 1.0f + sc->GetAvgRayContribution() - mMaxAvgRayContri; 
     785                cout << "here5 " << factor << endl; 
     786 
     787                mem *= factor; 
     788        } 
     789         
     790        mHierarchyStats.mMemory += mem; 
    772791        mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease(); 
    773792         
    774793        mPriority = sc->GetPriority(); 
     794 
     795        ////////// 
     796        // show current memory 
    775797 
    776798        static float memoryCount = 0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1893 r1895  
    575575        OspTree *mOspTree; 
    576576 
    577         public: 
     577        // quick hack: 
     578public: 
    578579        /// bounding volume hierarchy 
    579580        BvHierarchy *mBvHierarchy; 
    580581         
     582        float mMaxAvgRayContri; 
     583 
    581584protected: 
    582585 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h

    r1733 r1895  
    2222        enum {OBJECT_SPACE, VIEW_SPACE}; 
    2323 
    24         SubdivisionCandidate(): mRenderCostDecrease(0), mDirty(true) {}; 
     24        SubdivisionCandidate():  
     25                mRenderCostDecrease(0),  
     26                mAvgRayContribution(0),  
     27                mDirty(true)  
     28                {} 
    2529 
    2630        virtual ~SubdivisionCandidate() {}; 
     31         
    2732        /** Evaluate this subdivision candidate. 
    2833        */ 
    2934        virtual void EvalCandidate(bool computeSplitplane = true) = 0; 
     35         
    3036        /** Returns type of this subdivision candidate. 
    3137        */ 
    3238        virtual int Type() const = 0; 
     39         
    3340        /** Evaluate this candidate and put results into queue for further traversal. 
    3441        */ 
    3542        virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) = 0; 
     43         
    3644        /** Returns true of the global termination criteria of this split were met, 
    3745                false otherwise. 
    3846        */ 
    3947        virtual bool GlobalTerminationCriteriaMet() const = 0; 
     48         
    4049        /** Collects subdivision candidates that were affected by the 
    4150                application of this one. 
     
    5463        { 
    5564                return mRenderCostDecrease; 
     65        } 
     66 
     67        /** The average ray contribution of this candidate . 
     68                This is somewhat of a confidence value into the computed values. If 
     69                it is high, there is likely to be a lot of undersampling. 
     70        */ 
     71        inline void SetAvgRayContribution(const float rayContri) 
     72        { 
     73                mAvgRayContribution = rayContri; 
     74        } 
     75         
     76        inline float GetAvgRayContribution() const 
     77        { 
     78                return mAvgRayContribution; 
    5679        } 
    5780 
     
    139162        int mPvsEntriesIncr; 
    140163 
     164        /// the average ray contribution of this candidate  
     165        float mAvgRayContribution; 
     166 
    141167        int mMailbox; 
    142168 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1891 r1895  
    51085108: ViewCellsManager(vcTree), mHierarchyManager(hm) 
    51095109{ 
    5110         //cout<<"here4"<<endl; 
    51115110        Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", mInitialSamples); 
    51125111        Environment::GetSingleton()->GetBoolValue("ViewCells.compressObjects", mCompressObjects); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1893 r1895  
    856856        } 
    857857 
     858 
    858859        ///////////// 
    859860        // avg ray contri 
    860861 
    861         const float avgRayContri = splitCandidate.mParentData.GetAvgRayContribution(); 
    862         cout << "vsp avgRayContri: " << avgRayContri << endl; 
    863  
    864         // avg ray contri very high. i.e., the result is influenced by undersampling 
    865         // => decrease priority 
    866         if (avgRayContri > 99925) 
    867         { 
    868                 priority /= avgRayContri; 
     862        if (0) 
     863        { 
     864                const int pvs = EvalPvsEntriesSize(*splitCandidate.mParentData.mRays); 
     865                const float avgRayContri = (float)pvs / ((float)splitCandidate.mParentData.mRays->size() + Limits::Small); 
     866 
     867                Debug << "vsp avgRayContri: " << avgRayContri << " #pvs: " << pvs << " #rays: " << splitCandidate.mParentData.mRays->size() << endl; 
     868                cout << "vsp avgRayContri: " << avgRayContri << endl; 
     869 
     870                // high avg ray contri very, the result is influenced by undersampling 
     871                // => decrease priority 
     872                if (0 && (avgRayContri > mHierarchyManager->mMaxAvgRayContri)) 
     873                { 
     874                        const float factor = 1.0f + avgRayContri - mHierarchyManager->mMaxAvgRayContri; 
     875                        priority /= factor; 
     876                } 
     877 
     878                splitCandidate.SetAvgRayContribution(avgRayContri); 
    869879        } 
    870880 
     
    966976                parent->ReplaceChildLink(leaf, interior); 
    967977                interior->SetParent(parent); 
     978 
    968979#if WORK_WITH_VIEWCELLS 
    969980                // remove "parent" view cell from pvs of all objects (traverse trough rays) 
Note: See TracChangeset for help on using the changeset viewer.