Changeset 1666


Ignore:
Timestamp:
10/23/06 15:37:18 (18 years ago)
Author:
mattausch
Message:

working on render cost evaluation framework for interleaved splits

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.sh

    r1664 r1666  
    102102  echo "$SCENE $METHOD" 
    103103 
    104 # $PROGRAM $ENVIRONMENT \ 
     104 $PROGRAM $ENVIRONMENT \ 
    105105  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    106106  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     
    134134 
    135135############################################################### 
    136  
    137  METHOD=gradient-2 
     136MEMCONST=1.0 
     137 METHOD=gradient-$MEMCONST 
    138138 echo ********" $SCENE $METHOD ************" 
    139139 
     
    148148 -hierarchy_construction_levels=4 \ 
    149149 -hierarchy_construction_consider_memory=true \ 
     150 -hierarchy_term_memory_const=$MEMCONST \ 
     151 -bvh_construction_render_cost_decrease_weight=0.99 \ 
     152 -vsp_construction_render_cost_decrease_weight=0.99 \ 
     153 -hierarchy_construction_recompute_split_on_repair=true 
     154 
     155sh movefiles.sh $LOG_PREFIX-$METHOD 
     156 
     157######################################################################### 
     158 
     159MEMCONST=0.1 
     160 METHOD=gradient-$MEMCONST 
     161 echo ********" $SCENE $METHOD ************" 
     162 
     163 $PROGRAM $ENVIRONMENT \ 
     164 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     165 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     166 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     167 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     168 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     169 -hierarchy_construction_type=2 \ 
     170 -hierarchy_construction_multilevel=false \ 
     171 -hierarchy_construction_levels=4 \ 
     172 -hierarchy_construction_consider_memory=true \ 
     173 -hierarchy_term_memory_const=$MEMCONST \ 
    150174 -bvh_construction_render_cost_decrease_weight=0.99 \ 
    151175 -vsp_construction_render_cost_decrease_weight=0.99 \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1665 r1666  
    551551                        //cout << "here7 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 
    552552                        //priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr();// / mBvhStats.Leaves(); 
    553                         priority /= ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f); 
     553                        priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 
    554554                } 
    555555        } 
     
    589589                //cout << "here5 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 
    590590                //const float priority = factor * renderCostDecr - (1.0f - factor) * (float)splitCandidate.GetPvsEntriesIncr(); 
    591                 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f); 
     591                priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 
    592592        } 
    593593         
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1664 r1666  
    182182        void SetParent(BvhInterior *parent); 
    183183 
    184         // collects all objects under this node 
     184        /** collects all objects under this node. 
     185        */ 
    185186        virtual void CollectObjects(ObjectContainer &objects) = 0; 
     187 
    186188        /** The bounding box specifies the node extent. 
    187189        */ 
     
    190192        { return mBoundingBox; } 
    191193 
    192  
     194        /** Sets bouding box of this node. 
     195        */ 
    193196        inline  
    194197        void SetBoundingBox(const AxisAlignedBox3 &boundingBox)  
    195198        { mBoundingBox = boundingBox; } 
    196199 
     200 
     201        float GetMergeCost() {return 0.0f; }; 
    197202 
    198203        ///////////////////////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1665 r1666  
    25372537                                        "1"); 
    25382538 
     2539        RegisterOption("Hierarchy.Termination.memoryConst", 
     2540                                        optFloat, 
     2541                                        "hierarchy_term_memory_const=", 
     2542                                        "1.0"); 
     2543 
    25392544        RegisterOption("Hierarchy.Construction.useMultiLevel", 
    25402545                                        optBool, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1664 r1666  
    125125                "Hierarchy.Termination.maxMemory", mTermMaxMemory); 
    126126 
     127        Environment::GetSingleton()->GetFloatValue( 
     128                "Hierarchy.Termination.memoryConst", mMemoryConst); 
     129 
    127130        // compare to bytes 
    128131        mTermMaxMemory *= (1024.0f * 1024.0f); 
     
    139142        Debug << "maximal allowed memory: " << mTermMaxMemory << endl; 
    140143        Debug << "consider mem: " << mConsiderMemory << endl; 
     144        Debug << "mem const: " << mMemoryConst << endl; 
    141145 
    142146        switch (mConstructionType) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1663 r1666  
    530530        */ 
    531531        bool mConsiderMemory; 
     532 
     533        float mMemoryConst; 
    532534}; 
    533535 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1660 r1666  
    15251525{ 
    15261526        TraversalQueue tqueue; 
    1527  
    15281527        tqueue.push(mRoot); 
     1528 
    15291529        int numViewCells = 1; 
    15301530         
     
    15351535        const int rootEntries = GetPvsEntries(mRoot); 
    15361536 
    1537         Debug << "******** Export stats **********" << endl; 
     1537        cout << "exporting stats ... " << endl; 
    15381538         
    15391539        float totalRenderCost, avgRenderCost, expectedCost; 
     
    21512151{ 
    21522152        TraversalQueue tqueue; 
    2153          
    21542153        tqueue.push(mRoot); 
    21552154         
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1660 r1666  
    55125512        { 
    55135513                ViewCell *viewcell = *it; 
    5514                  
     5514 
    55155515                if (viewcell->GetValid()) 
    55165516                {       // if ray not outside of view space 
     
    55195519                        if (ray.mTerminationObject)  
    55205520                        { 
    5521                           // todo: maybe not correct for kd node pvs 
    5522                           Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 
    5523                            
    5524                           if (viewcell->GetPvs().GetSampleContribution(obj, 
    5525                                                                                                                    ray.mPdf,  
    5526                                                                                                                    contribution)) 
     5521                                // todo: maybe not correct for kd node pvs 
     5522                                Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 
     5523 
     5524                                if (viewcell->GetPvs().GetSampleContribution(obj, 
     5525                                        ray.mPdf,  
     5526                                        contribution)) 
    55275527                                { 
    5528                                   ++ ray.mPvsContribution; 
     5528                                        ++ ray.mPvsContribution; 
    55295529                                } 
    5530                            
    5531                           ray.mRelativePvsContribution += contribution; 
     5530 
     5531                                ray.mRelativePvsContribution += contribution; 
    55325532                        } 
    5533                          
    5534                         // for directional sampling it is important to count only contributions 
    5535                         // made in one direction! 
    5536                         // the other contributions of this sample will be counted for the opposite ray! 
     5533 
     5534                        //-- for directional sampling it is important to count only contributions  
     5535                        //-- made in one direction! 
     5536                        //-- the other contributions of this sample will be counted for the opposite ray! 
    55375537#if SAMPLE_ORIGIN_OBJECTS 
    55385538                        if (ray.mOriginObject &&  
    55395539                                viewcell->GetPvs().GetSampleContribution(ray.mOriginObject, 
    5540                                                                                                                  ray.mPdf, 
    5541                                                                                                                  contribution)) 
     5540                                ray.mPdf, 
     5541                                contribution)) 
    55425542                        { 
    55435543                                ++ ray.mPvsContribution; 
     
    56165616 
    56175617 
     5618typedef priority_queue<ViewCell *, vector<ViewCell *>,  
     5619                                           myless<vector<ViewCell *>::value_type> > ViewCellsQueue; 
     5620 
     5621typedef priority_queue<BvhNode *, vector<BvhNode *>,  
     5622                                           myless<vector<BvhNode *>::value_type> > ObjectsQueue; 
     5623 
     5624void VspOspViewCellsManager::ExportStats(const string &mergeStats) 
     5625{ 
     5626        ofstream stats; 
     5627        stats.open(mergeStats.c_str()); 
     5628 
     5629        ObjectsQueue objectsQueue; 
     5630        ViewCellsQueue viewCellsQueue; 
     5631 
     5632        objectsQueue.push(mHierarchyManager->mBvHierarchy->GetRoot()); 
     5633        viewCellsQueue.push(mViewCellsTree->GetRoot()); 
     5634         
     5635        int numViewCells = 1; 
     5636         
     5637        const AxisAlignedBox3 box = mViewSpaceBox; 
     5638        const float vol = box.GetVolume(); 
     5639 
     5640        const int rootPvs = mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot()); 
     5641        const int rootEntries = mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot()); 
     5642 
     5643        cout << "exporting stats ... " << endl; 
     5644         
     5645        float totalRenderCost, avgRenderCost, expectedCost; 
     5646 
     5647        float deviation = 0; 
     5648        int totalPvs = rootPvs; 
     5649        int entriesInPvs = rootEntries; 
     5650 
     5651        totalRenderCost = avgRenderCost = expectedCost = (float)rootPvs; 
     5652 
     5653        const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 
     5654        const float memoryCost = (float)entriesInPvs *  entrySize / (1024.0f * 1024.0f); 
     5655 
     5656        ///////////// 
     5657        //-- first view cell 
     5658 
     5659/*      mViewCellsTree->UpdateStats(stats,       
     5660                                                                0,  
     5661                                                                numViewCells,  
     5662                                                                0,  
     5663                                                                totalRenderCost,  
     5664                                                                rootPvs,  
     5665                                                                expectedCost,  
     5666                                                                avgRenderCost,  
     5667                                                                deviation, 
     5668                                                                totalPvs,  
     5669                                                                entriesInPvs, 
     5670                                                                memoryCost, 
     5671                                                                0,  
     5672                                                                mRoot->GetVolume()); 
     5673*/               
     5674 
     5675        //-- go through tree in the order of render cost decrease 
     5676        //-- which is the same order as the view cells were merged 
     5677        //-- or the reverse order of subdivision for subdivision-only  
     5678        //-- view cell hierarchies. 
     5679 
     5680        while (!(objectsQueue.empty() && viewCellsQueue.empty())) 
     5681        { 
     5682                ViewCell *viewCell = viewCellsQueue.top(); 
     5683                BvhNode *bvhNode =  objectsQueue.top(); 
     5684 
     5685                if (viewCell->GetMergeCost() < bvhNode->GetMergeCost()) 
     5686                { 
     5687                        viewCellsQueue.pop(); 
     5688/* 
     5689                        if (!vc->IsLeaf())  
     5690                        {        
     5691                                ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     5692 
     5693                                const int parentPvs = GetPvsSize(interior); 
     5694                                const int parentPvsEntries = GetPvsEntries(interior); 
     5695                                const float parentCost = (float)parentPvs * interior->GetVolume(); 
     5696 
     5697                                float childCost = 0; 
     5698                                int childPvs = 0; 
     5699                                int childPvsEntries = 0; 
     5700 
     5701                                -- numViewCells; 
     5702 
     5703                                ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     5704 
     5705                                for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     5706                                { 
     5707                                        ViewCell *vc = *it; 
     5708 
     5709                                        const int pvsSize = GetPvsSize(vc); 
     5710                                        const int pvsEntries = GetPvsEntries(vc); 
     5711         
     5712                                        childCost += (float) pvsSize * vc->GetVolume(); 
     5713                                        childPvs += pvsSize; 
     5714                                        childPvsEntries += pvsEntries; 
     5715 
     5716                                        tqueue.push(vc); 
     5717                                        ++ numViewCells; 
     5718                                } 
     5719 
     5720                                // update stats for this view cell 
     5721                                const float costDecr = (parentCost - childCost) / vol; 
     5722 
     5723                                totalRenderCost -= costDecr; 
     5724                                totalPvs += childPvs - parentPvs; 
     5725                                entriesInPvs += childPvsEntries - parentPvsEntries; 
     5726 
     5727                                expectedCost = totalRenderCost / (float)numViewCells; 
     5728                                avgRenderCost = (float)totalPvs / (float)numViewCells; 
     5729 
     5730                                const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 
     5731                                const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f); 
     5732 
     5733                                mViewCellsTree->UpdateStats(stats, 
     5734                                                                                        0,  
     5735                                                                                        numViewCells,  
     5736                                                                                        costDecr,  
     5737                                                                                        totalRenderCost, 
     5738                                                                                        parentPvs,  
     5739                                                                                        expectedCost,  
     5740                                                                                        avgRenderCost,  
     5741                                                                                        deviation, 
     5742                                                                                        totalPvs,  
     5743                                                                                        entriesInPvs,  
     5744                                                                                        memoryCost, 
     5745                                                                                        childPvs - parentPvs, 
     5746                                                                                        vc->GetVolume()); 
     5747                                */ 
     5748                        } 
     5749                        else // object space split 
     5750                        { 
     5751                        } 
     5752        } 
     5753 
     5754        stats.close(); 
     5755} 
     5756 
     5757 
    56185758#if TEST_EVALUATION 
    56195759void VspOspViewCellsManager::EvalViewCellPartition() 
     
    56935833        cout << "finished" << endl; 
    56945834 
    5695         vector<int> storageFunc; 
    5696         mViewCellsTree->GetStorageFunction(storageFunc); 
    5697  
    5698         vector<float> costFunc; 
    5699         mViewCellsTree->GetCostFunction(costFunc); 
    5700  
    5701         ofstream outstr("out.txt"); 
    5702  
    5703         for (int i = 0; i < storageFunc.size(); ++ i) 
    5704                 outstr << i << ": " << storageFunc[i] << endl; 
    5705 outstr << endl; 
    5706         for (int i = 0; i < costFunc.size(); ++ i) 
    5707                 outstr << i << ": " << costFunc[i] << endl; 
    5708         if (0) 
    5709         for (int i = 0; i <50; ++ i) 
    5710         { 
    5711                 Vector3 point = GetViewSpaceBox().GetRandomPoint(); 
    5712                 ViewCell *vc = GetViewCell(point); 
    5713         } 
    5714         //RenderBvhNode(mHierarchyManager->mBvHierarchy->GetRoot()); 
    5715  
    57165835        disposeRays(evaluationSamples, NULL); 
    57175836} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1662 r1666  
    10831083 
    10841084        ViewCellsManager *LoadViewCells(const string &filename,  
    1085                 ObjectContainer *objects, 
    1086                 const bool finalizeViewCells, 
    1087                 BoundingBoxConverter *bconverter); 
    1088  
    1089         bool AddSampleToPvs( 
    1090                 Intersectable *obj,  
    1091                 const Vector3 &hitPoint, 
    1092                 ViewCell *vc, 
    1093                 const float pdf,  
    1094         float &contribution) const; 
    1095  
    1096         void ExportSingleViewCells( 
    1097                 const ObjectContainer &objects, 
    1098                 const int maxViewCells, 
    1099                 const bool sortViewCells, 
    1100                 const bool exportPvs, 
    1101                 const bool exportRays, 
    1102                 const int maxRays, 
    1103                 const string prefix, 
    1104                 VssRayContainer *visRays = NULL); 
     1085                                                                        ObjectContainer *objects, 
     1086                                                                        const bool finalizeViewCells, 
     1087                                                                        BoundingBoxConverter *bconverter); 
     1088 
     1089        bool AddSampleToPvs(Intersectable *obj,  
     1090                                                const Vector3 &hitPoint, 
     1091                                                ViewCell *vc, 
     1092                                                const float pdf,  
     1093                                                float &contribution) const; 
     1094 
     1095        void ExportSingleViewCells(const ObjectContainer &objects, 
     1096                                                           const int maxViewCells, 
     1097                                                           const bool sortViewCells, 
     1098                                                           const bool exportPvs, 
     1099                                                           const bool exportRays, 
     1100                                                           const int maxRays, 
     1101                                                           const string prefix, 
     1102                                                           VssRayContainer *visRays = NULL); 
    11051103 
    11061104protected: 
     
    11121110        /** Exports view cell geometry. 
    11131111        */ 
    1114         void ExportViewCellGeometry( 
    1115                 Exporter *exporter, 
    1116                 ViewCell *vc, 
    1117                 const AxisAlignedBox3 *box, 
    1118                 const AxisAlignedPlane *clipPlane = NULL 
    1119                 ) const; 
    1120  
    1121         int ComputeBoxIntersections( 
    1122                 const AxisAlignedBox3 &box,  
    1123                 ViewCellContainer &viewCells) const; 
     1112        void ExportViewCellGeometry(Exporter *exporter, 
     1113                                                                ViewCell *vc, 
     1114                                                                const AxisAlignedBox3 *box, 
     1115                                                                const AxisAlignedPlane *clipPlane = NULL) const; 
     1116 
     1117        int ComputeBoxIntersections(const AxisAlignedBox3 &box,  
     1118                                                                ViewCellContainer &viewCells) const; 
    11241119         
    11251120        void CollectViewCells(); 
     
    11351130        /** Exports visualization of the PVS. 
    11361131        */ 
    1137         void ExportPvs( 
    1138                 const ObjectContainer &objects, 
    1139                 const VssRayContainer &rays); 
    1140  
     1132        void ExportPvs(const ObjectContainer &objects, const VssRayContainer &rays); 
     1133 
     1134        void ExportStats(const string &mergeStats); 
    11411135 
    11421136        ///////////////////////////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1665 r1666  
    828828                //cout << "here4 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 
    829829                //const float priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr(); 
    830                 priority /= ((float)splitCandidate.GetPvsEntriesIncr() +  + 1.0f); 
     830                priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 
    831831        } 
    832832         
     
    853853                //cout << "here2 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl;  
    854854                //const float priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr(); 
    855                 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f); 
     855                priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 
    856856        } 
    857857 
Note: See TracChangeset for help on using the changeset viewer.