Changeset 1662


Ignore:
Timestamp:
10/22/06 09:03:24 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
10 edited

Legend:

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

    r1660 r1662  
    6161################################################################################## 
    6262 
    63  METHOD=gradient 
     63 METHOD=gradient-mem 
    6464 echo "$SCENE $METHOD" 
    6565 
     
    7171  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
    7272  -hierarchy_construction_type=2 \ 
     73  -hierarchy_construction_consider_memory=true \ 
    7374  -hierarchy_construction_multilevel=false \ 
    7475  -hierarchy_construction_recompute_split_on_repair=true 
     
    134135######################################################################## 
    135136 
    136 # METHOD=gradient_simplesplit 
    137 # echo "$SCENE $METHOD" 
     137METHOD=gradient_simplesplit 
     138echo "$SCENE $METHOD" 
    138139 
    139 #$PROGRAM $ENVIRONMENT \ 
    140 # -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    141 # -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
    142 #  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
    143 #  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
    144 #  -bvh_use_sah=true \ 
    145 #  -vsp_use_cost_heuristics=false \ 
    146 #  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
    147 #  -hierarchy_construction_type=2 \ 
    148 #  -hierarchy_construction_recompute_split_on_repair=true 
     140$PROGRAM $ENVIRONMENT \ 
     141 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     142 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     143  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     144  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     145  -bvh_use_sah=true \ 
     146  -vsp_use_cost_heuristics=true \ 
     147  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     148  -hierarchy_construction_type=2 \ 
     149  -hierarchy_construction_recompute_split_on_repair=true 
    149150 
    150151sh movefiles.sh $LOG_PREFIX-$METHOD 
     
    167168 
    168169sh movefiles.sh $LOG_PREFIX-$METHOD 
     170 
     171########################################################## 
     172 METHOD=gradient-500 
     173 echo "$SCENE $METHOD" 
     174 
     175  $PROGRAM $ENVIRONMENT \ 
     176  -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
     177  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     178  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     179  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     180  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     181  -hierarchy_construction_type=2 \ 
     182  -hierarchy_construction_consider_memory=false \ 
     183  -hierarchy_construction_min_steps_same_type=500 \ 
     184  -hierarchy_construction_multilevel=false \ 
     185  -hierarchy_construction_recompute_split_on_repair=true 
     186 
     187sh movefiles.sh $LOG_PREFIX-$METHOD 
     188 
     189 
     190############################################################################ 
     191 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1654 r1662  
    2525#define PROBABILIY_IS_BV_VOLUME 1 
    2626#define USE_FIXEDPOINT_T 0 
    27 //#define COUNT_ORIGIN_OBJECTS 0 
     27 
     28#define USE_VOLUMES_FOR_HEURISTICS 1 
     29 
    2830 
    2931int BvhNode::sMailId = 10000; //2147483647; 
     
    261263        Environment::GetSingleton()->GetBoolValue("BvHierarchy.Construction.useGlobalSorting", mUseGlobalSorting); 
    262264 
     265        mUseBboxAreaForSah = true; 
    263266 
    264267        ///////////// 
     
    432435                // decrease the weighted average cost of the subdivisoin 
    433436                mTotalCost -= sc->GetRenderCostDecrease(); 
     437                mPvsEntries += sc->GetPvsEntriesIncr(); 
    434438 
    435439                // subdivision statistics 
     
    527531                //-- surface area heuristics 
    528532 
    529         //      if (objects.empty()) 
    530         //              return 0.0f; 
    531  
    532533                const AxisAlignedBox3 box = EvalBoundingBox(leaf->mObjects); 
    533534                const float area = box.SurfaceArea(); 
     
    814815        int objectsLeft = 0, objectsRight = (int)tData.mNode->mObjects.size(); 
    815816   
    816         AxisAlignedBox3 box = tData.mNode->GetBoundingBox(); 
    817  
    818         float minBox = box.Min(axis); 
    819         float maxBox = box.Max(axis); 
    820         float boxArea = box.SurfaceArea(); 
     817        const AxisAlignedBox3 nodeBbox = tData.mNode->GetBoundingBox(); 
     818 
     819        const float minBox = nodeBbox.Min(axis); 
     820        const float maxBox = nodeBbox.Max(axis); 
     821        const float boxArea = nodeBbox.SurfaceArea(); 
    821822 
    822823        float minSum = 1e20f; 
     
    828829        SortableEntryContainer::const_iterator currentPos = 
    829830                mSubdivisionCandidates->begin(); 
    830  
    831          
    832         // we keep track of both borders of the bounding boxes => 
    833         // store the events in descending order 
     831         
    834832        vector<float> bordersRight; 
    835         bordersRight.resize(mSubdivisionCandidates->size()); 
    836  
    837         SortableEntryContainer::reverse_iterator rcit =  
    838                 mSubdivisionCandidates->rbegin(), rcit_end = mSubdivisionCandidates->rend(); 
    839          
    840         vector<float>::reverse_iterator rbit = bordersRight.rbegin(); 
    841          
    842         for (; rcit != rcit_end; ++ rcit, ++ rbit)  
    843         { 
    844                 Intersectable *obj = (*rcit).mObject; 
    845                 const AxisAlignedBox3 box = obj->GetBox(); 
    846  
    847                 if (box.Min(axis) < minBorder) 
    848                 { 
    849                         minBorder = box.Min(axis); 
    850                 } 
    851  
    852                 (*rbit) = minBorder; 
    853         } 
     833 
     834        if (mUseBboxAreaForSah) 
     835        { 
     836                // we keep track of both borders of the bounding boxes => 
     837                // store the events in descending order 
     838 
     839                bordersRight.resize(mSubdivisionCandidates->size()); 
     840 
     841                SortableEntryContainer::reverse_iterator rcit =  
     842                        mSubdivisionCandidates->rbegin(), rcit_end = mSubdivisionCandidates->rend(); 
     843         
     844                vector<float>::reverse_iterator rbit = bordersRight.rbegin(); 
     845         
     846                for (; rcit != rcit_end; ++ rcit, ++ rbit)  
     847                { 
     848                        Intersectable *obj = (*rcit).mObject; 
     849                        const AxisAlignedBox3 obox = obj->GetBox(); 
     850 
     851                        if (obox.Min(axis) < minBorder) 
     852                        { 
     853                                minBorder = obox.Min(axis); 
     854                        } 
     855 
     856                        (*rbit) = minBorder; 
     857                } 
     858        } 
     859 
     860        // temporary surface areas 
     861        float al = 0; 
     862        float ar = boxArea; 
    854863 
    855864        vector<float>::const_iterator bit = bordersRight.begin(); 
     
    863872                -- objectsRight; 
    864873 
    865                 AxisAlignedBox3 lbox = box; 
    866                 AxisAlignedBox3 rbox = box; 
    867          
    868874                const AxisAlignedBox3 obox = obj->GetBox(); 
    869875 
    870                 // the borders of the bounding boxes have changed 
    871                 if (obox.Max(axis) > maxBorder) 
    872                 { 
    873                         maxBorder = obox.Max(axis); 
    874                 } 
    875  
    876                 minBorder = (*bit); 
    877          
    878         lbox.SetMax(axis, maxBorder); 
    879                 rbox.SetMin(axis, minBorder); 
    880          
    881                 const float al = lbox.SurfaceArea(); 
    882                 const float ar = rbox.SurfaceArea(); 
     876                if (mUseBboxAreaForSah) 
     877                { 
     878                        AxisAlignedBox3 lbox = nodeBbox; 
     879                        AxisAlignedBox3 rbox = nodeBbox; 
     880         
     881                        // the borders of the bounding boxes have changed 
     882                        if (obox.Max(axis) > maxBorder) 
     883                        { 
     884                                maxBorder = obox.Max(axis); 
     885                        } 
     886 
     887                        minBorder = (*bit); 
     888 
     889                        lbox.SetMax(axis, maxBorder); 
     890                        rbox.SetMin(axis, minBorder); 
     891         
     892                        al = lbox.SurfaceArea(); 
     893                        ar = rbox.SurfaceArea(); 
     894                } 
     895                else 
     896                { 
     897                        // just add up areas of the object bbs 
     898                        // (as we are not sampling volumetric visibility, 
     899                        // this should provide better heuristics 
     900                        const float area = obox.SurfaceArea(); 
     901 
     902                        al += area; 
     903                        ar -= area; 
     904                } 
    883905 
    884906                const float sum = objectsLeft * al + objectsRight * ar; 
     
    11511173        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    11521174        { 
    1153                 vol += (*vit)->GetVolume(); 
     1175#if USE_VOLUMES_FOR_HEURISTICS 
     1176                const float volIncr = (*vit)->GetVolume(); 
     1177#else 
     1178                const float volIncr = 1.0f; 
     1179#endif 
     1180                vol += volIncr; 
    11541181        } 
    11551182 
     
    11851212                // view cells can also be seen from left child node 
    11861213                ViewCell *viewCell = *vit; 
    1187  
     1214#if USE_VOLUMES_FOR_HEURISTICS 
    11881215                const float vol = viewCell->GetVolume(); 
    1189  
     1216#else 
     1217                const float vol = 1.0f; 
     1218#endif 
    11901219                if (!viewCell->Mailed()) 
    11911220                { 
     
    13521381                        << "#Leaves\n" << mBvhStats.Leaves() << endl 
    13531382                        << "#RenderCostDecrease\n" << costDecr << endl  
    1354                         << "#TotalRenderCost\n" << mTotalCost << endl; 
     1383                        << "#TotalRenderCost\n" << mTotalCost << endl 
     1384                        << "#EntriesInPvs\n" << mPvsEntries << endl; 
    13551385} 
    13561386 
     
    18811911        const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 
    18821912        mTotalCost = (float)objects.size() * prop / viewSpaceVol; 
     1913        mPvsEntries = CountViewCells(objects); 
    18831914 
    18841915        PrintSubdivisionStats(*oSubdivisionCandidate); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1643 r1662  
    886886        /// keeps track of cost during subdivision 
    887887        float mTotalCost; 
     888        int mPvsEntries; 
    888889        /// keeps track of overall pvs size during subdivision 
    889890        int mTotalPvsSize; 
     
    899900        bool mUseGlobalSorting; 
    900901 
     902        bool mUseBboxAreaForSah; 
     903 
    901904        SortableEntryContainer *mSortedObjects[3]; 
    902905}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1653 r1662  
    25172517                                        "true"); 
    25182518 
     2519        RegisterOption("Hierarchy.Construction.considerMemory", 
     2520                                        optBool, 
     2521                                        "hierarchy_construction_consider_memory=", 
     2522                                        "false"); 
     2523 
    25192524        RegisterOption("Hierarchy.Construction.repairQueue", 
    25202525                                        optBool, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1661 r1662  
    119119                "Hierarchy.Construction.recomputeSplitPlaneOnRepair", mRecomputeSplitPlaneOnRepair); 
    120120 
     121        Environment::GetSingleton()->GetBoolValue( 
     122                "Hierarchy.Construction.considerMemory", mConsiderMemory); 
     123 
    121124        Environment::GetSingleton()->GetFloatValue( 
    122125                "Hierarchy.Termination.maxMemory", mTermMaxMemory); 
    123126 
     127        // compare to bytes 
    124128        mTermMaxMemory *= (1024.0f * 1024.0f); 
    125129 
     
    134138        Debug << "minimal number of steps from same type: " << mMinStepsOfSameType << endl; 
    135139        Debug << "maximal allowed memory: " << mTermMaxMemory << endl; 
     140        Debug << "consider mem: " << mConsiderMemory << endl; 
    136141 
    137142        switch (mConstructionType) 
     
    350355        mHierarchyStats.mTotalCost = (float)objects.size(); 
    351356        mHierarchyStats.mPvsEntries = 1; 
    352         mHierarchyStats.mMemory = sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
     357 
     358        const int entrySize = sizeof(PvsData) + sizeof(Intersectable *); 
     359        mHierarchyStats.mMemory = entrySize / (1024.0f * 1024.0f); 
    353360 
    354361        EvalSubdivisionStats(); 
     
    365372        mSavedViewSpaceSubdivisionType = mViewSpaceSubdivisionType; 
    366373        mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 
    367         //mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 
     374        mSavedObjectSpaceSubdivisionType = mObjectSpaceSubdivisionType; 
    368375 
    369376        // number of initial splits 
     
    404411        ResetQueue(objectSpaceQueue, false); 
    405412 
    406          
    407         // lower number of minsteps: the decicion of which domain to subdivide 
    408         // should be decided using the render cost decrease from now 
    409413        //minSteps = 1; 
    410414 
     
    417421        while (!(viewSpaceQueue.Empty() && objectSpaceQueue.Empty())) 
    418422        { 
    419                 const float vspPriority = viewSpaceQueue.Empty() ? 0 :  
    420                         viewSpaceQueue.Top()->GetPriority() / ((float)viewSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small); 
    421                 const float ospPriority = objectSpaceQueue.Empty() ? 0 :  
    422                         objectSpaceQueue.Top()->GetPriority() / ((float)objectSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small); 
     423                float vspPriority; 
     424                 
     425                // decide upon next split type 
     426                if (!viewSpaceQueue.Empty()) 
     427                { 
     428                        vspPriority = viewSpaceQueue.Top()->GetPriority(); 
     429 
     430                        if (mConsiderMemory) 
     431                                vspPriority /= ((float)viewSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small); 
     432                } 
     433                else 
     434                { 
     435                        vspPriority = 0; 
     436                } 
     437 
     438                float ospPriority = 0; 
     439                 
     440                if (!objectSpaceQueue.Empty()) 
     441                { 
     442                        ospPriority = objectSpaceQueue.Top()->GetPriority(); 
     443                 
     444                        if (mConsiderMemory) 
     445                                ospPriority /= ((float)objectSpaceQueue.Top()->GetPvsEntriesIncr() + Limits::Small); 
     446                } 
     447                else 
     448                { 
     449                        ospPriority = 0; 
     450                } 
    423451 
    424452                cout << "new decicion, vsp: " << vspPriority << ", osp: " << ospPriority << endl; 
     
    567595 
    568596        mHierarchyStats.mTotalCost = mVspTree->mTotalCost; 
    569         mHierarchyStats.mPvsEntries = mVspTree->EvalPvsEntriesSize(*viewSpaceRays); 
    570         mHierarchyStats.mMemory = mHierarchyStats.mPvsEntries *  
    571                 sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
    572  
     597         
    573598        cout << "\nreseting cost for vsp, new total cost: " << mHierarchyStats.mTotalCost << endl; 
    574599 
     
    933958         
    934959                        // rather use this: remove previous nodes and add the two new ones 
    935                         //mHierarchyStats.mNodes -= mBvHierarchy->mBvhStats.nodes + 2; 
    936                         mHierarchyStats.mNodes = 2; 
    937  
    938                         //firstCandidate = mBvHierarchy->PrepareConstruction(sampleRays, objects); 
     960                        mHierarchyStats.mNodes -= mBvHierarchy->mBvhStats.nodes + 1; 
     961                         
    939962                        firstCandidate = mBvHierarchy->Reset(sampleRays, objects); 
    940963 
    941964                        mHierarchyStats.mTotalCost = mBvHierarchy->mTotalCost; 
    942                         mHierarchyStats.mRenderCostDecrease = 0; 
    943  
    944                         // bug!! pvs entries cab be much higher at this stage 
    945                         // (if view space was already subdivided) 
     965                        //mHierarchyStats.mPvsEntries -= mBvHierarchy->mPvsEntries + 1; 
    946966                        mHierarchyStats.mPvsEntries = mBvHierarchy->CountViewCells(objects); 
    947967                        mHierarchyStats.mMemory = mHierarchyStats.mPvsEntries * 
    948968                                sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
     969 
     970                        mHierarchyStats.mRenderCostDecrease = 0; 
    949971 
    950972                        // evaluate stats before first subdivision 
     
    9801002        mVspTree->Initialise(sampleRays, forcedViewSpace); 
    9811003         
    982         mHierarchyStats.mNodes = -mVspTree->mVspStats.nodes + 1; 
     1004        //-- reset stats 
     1005    mHierarchyStats.mNodes = -mVspTree->mVspStats.nodes + 1; 
     1006         
     1007        SubdivisionCandidate *vsc = PrepareViewSpaceSubdivision(sampleRays, objects); 
     1008         
     1009        mHierarchyStats.mPvsEntries = mVspTree->mPvsEntries; 
    9831010        mHierarchyStats.mRenderCostDecrease = 0; 
    9841011 
    985         SubdivisionCandidate *vsc = PrepareViewSpaceSubdivision(sampleRays, objects); 
    986          
     1012        mHierarchyStats.mMemory = mHierarchyStats.mPvsEntries *  
     1013                sizeof(PvsData) + sizeof(Intersectable *) / (1024.0f * 1024.0f); 
     1014 
    9871015        // evaluate new stats before first subdivsiion 
    9881016        EvalSubdivisionStats(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1654 r1662  
    524524        */ 
    525525        bool mRecomputeSplitPlaneOnRepair; 
     526 
     527        /** If memory should be considered during choosing 
     528                of the next split type during gradient method. 
     529        */ 
     530        bool mConsiderMemory; 
    526531}; 
    527532 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1660 r1662  
    388388                        { 
    389389                                ExportBinaryObj("../data/test.bin", mSceneGraph->GetRoot()); 
    390                                 //Exporter *exporter = Exporter::GetExporter("dummy.wrl"); 
    391                                 //exporter->ExportGeometry(mSceneGraph->GetRoot()->mGeometry); 
    392390                        } 
    393391                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1608 r1662  
    10241024}; 
    10251025 
    1026 #define TEST_EVALUATION 1 
     1026#define TEST_EVALUATION 0 
    10271027 
    10281028/** 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1649 r1662  
    714714                mTotalCost -= sc->GetRenderCostDecrease(); 
    715715                mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; 
     716                mPvsEntries += sc->GetPvsEntriesIncr(); 
    716717 
    717718                // subdivision statistics 
     
    29142915 
    29152916        mTotalCost = (float)pvsSize; 
     2917        mPvsEntries = EvalPvsEntriesSize(rays); 
     2918 
    29162919        EvalSubdivisionStats(*splitCandidate); 
    29172920 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1640 r1662  
    10881088        /// keeps track of cost during subdivision 
    10891089        float mTotalCost; 
     1090        int mPvsEntries; 
    10901091        /// keeps track of overall pvs size during subdivision 
    10911092        int mTotalPvsSize; 
Note: See TracChangeset for help on using the changeset viewer.