Changeset 607


Ignore:
Timestamp:
02/08/06 18:25:17 (18 years ago)
Author:
mattausch
Message:

added method for associating spatial hierarchy leaf with view cell

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r605 r607  
    176176        # samples used for view cell construction 
    177177        Construction { 
    178                 samples 2500000 
     178                samples 2000000 
    179179                samplesPerPass 500000 
    180180        } 
    181181 
    182182        #number of active view cells 
    183         active 256 
     183        active 2048 
    184184        maxStaticMemory 40 
    185185 
     
    188188 
    189189        #type kdTree 
    190         type vspKdTree 
     190        #type vspKdTree 
    191191        #type bspTree 
    192192        type vspBspTree 
     
    214214                refine false 
    215215                compress false 
    216                 merge false 
     216                merge true 
    217217        } 
    218218 
     
    304304         
    305305        # maximal candidates for split planes 
    306         maxPolyCandidates 0 
     306        maxPolyCandidates 200 
    307307 
    308308         
    309309        # maximal tested rays for split cost heuristics 
    310         maxTests 20000 
     310        maxTests 10000 
    311311         
    312312        maxTotalMemory  50 
     
    320320        } 
    321321         
     322        usePolygonSplitIfAvailable 0 
     323 
    322324        Termination { 
    323325                # parameters used for autopartition 
    324                 minRays                 -1 
     326                minRays                 500 
    325327                minPolygons             -1 
    326                 maxDepth                40 
     328                maxDepth                25 
    327329                minPvs                  -1 
    328330                minProbability          0.0000001 
    329                 maxRayContribution      100000000.2 
    330                 maxCostRatio            9.85 
    331                 missTolerance           2 
    332                  
    333                 maxViewCells            2048 
     331                maxRayContribution      0.3 
     332                maxCostRatio            0.9 
     333                missTolerance           3 
     334                 
     335                maxViewCells            30000 
    334336                 
    335337                # used for pvs criterium 
     
    337339                 
    338340                AxisAligned { 
    339                         minRays                 1 
     341                        minRays                 900000 
    340342                        maxRayContribution      9.9 
    341343                } 
    342344        } 
    343345         
    344         splitUseOnlyDrivingAxis true 
     346        splitUseOnlyDrivingAxis false 
    345347         
    346348        Visualization { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r599 r607  
    19091909                                        "false"); 
    19101910 
     1911        RegisterOption("VspBspTree.usePolygonSplitIfAvailable", 
     1912                                        optBool, 
     1913                    "vsp_bsp_usePolygonSplitIfAvailable=", 
     1914                                        "true"); 
     1915 
    19111916        RegisterOption("VspBspTree.Termination.AxisAligned.minRays", 
    19121917                        optInt, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r605 r607  
    497497        cout << "actual merge starts now ... " << endl; 
    498498         
    499  
    500499        mStats << "#Pass\n" << pass << endl 
    501500                   << "#Merged\n" << mergeStats.merged << endl  
    502                    << "#Viewcells\n" << realNumActiveViewCells << endl  
     501                   << "#ViewCells\n" << realNumActiveViewCells << endl  
    503502                   << "#RenderCostIncrease\n" << 0 << endl 
    504503                   << "#TotalRenderCost\n" << totalRenderCost << endl 
     
    508507                   << "#Deviation\n" << mDeviation << endl 
    509508                   << "#TotalPvs\n" << totalPvs << endl 
    510                    << "#PvsSizeDecrease\n" << 0 << endl 
    511                    << "#Volume\n" << endl; 
     509                   << "#PvsSizeDecrease\n0" << endl 
     510                   << "#Volume\n" << endl 
     511                   << "#Siblings\n" << mergeStats.siblings << endl; 
    512512 
    513513        //-- use priority queue to merge leaf pairs 
     
    604604                        mergedVc->SetMergeCost(totalRenderCost); 
    605605 
    606 #if VC_HISTORY 
    607                         if (mc.mLeftViewCell->IsSibling(mc.mRightViewCell)) 
     606                        if (mViewCellsManager->EqualToSpatialNode(mergedVc)) 
    608607                                ++ mergeStats.siblings; 
    609 #endif 
     608 
    610609                        if (((mergeStats.merged % statsOut) == 0) ||  
    611610                        (realNumActiveViewCells == mMergeMinViewCells)) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r605 r607  
    113113 
    114114 
     115 
    115116/// helper function which destroys rays or copies them into the output ray container 
    116117inline void addOutRays(VssRayContainer &rays, VssRayContainer *outRays) 
     
    26122613 
    26132614 
     2615bool VspBspViewCellsManager::EqualToSpatialNode(ViewCell *viewCell) 
     2616{ 
     2617        BspNode *node; 
     2618        return EqualToSpatialNode(viewCell, &node); 
     2619} 
     2620 
     2621 
     2622bool VspBspViewCellsManager::EqualToSpatialNode(ViewCell *viewCell, BspNode **node) 
     2623{ 
     2624        if (!viewCell->IsLeaf()) 
     2625        { 
     2626                BspViewCell *bspVc = dynamic_cast<BspViewCell *>(viewCell); 
     2627 
     2628                *node = bspVc->mLeaf; 
     2629        return true; 
     2630        } 
     2631        else 
     2632        { 
     2633                ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(viewCell); 
     2634 
     2635                // cannot be node of binary tree 
     2636                if (interior->mChildren.size() != 2) 
     2637                        return false; 
     2638 
     2639                ViewCell *left = interior->mChildren[0]; 
     2640                ViewCell *right = interior->mChildren[1]; 
     2641 
     2642                BspNode *leftNode; 
     2643                BspNode *rightNode; 
     2644 
     2645                if (EqualToSpatialNode(left, &leftNode) && EqualToSpatialNode(right, &rightNode)) 
     2646                { 
     2647                        *node = leftNode->GetParent(); 
     2648                        return leftNode->IsSibling(rightNode);   
     2649                } 
     2650 
     2651                *node = NULL; 
     2652 
     2653                return false; 
     2654        } 
     2655} 
     2656 
     2657 
    26142658void VspBspViewCellsManager::RefineViewCells(const VssRayContainer &rays, 
    26152659                                                                                         const ObjectContainer &objects) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r605 r607  
    352352                                                                                vector<MergeCandidate> &candidates) = 0; 
    353353 
    354          
    355    
    356   void CollectViewCells(const int n) { 
    357         mNumActiveViewCells = n; 
    358         mViewCells.clear(); 
    359         CollectViewCells(); 
    360   } 
     354          
     355        void CollectViewCells(const int n)  
     356        { 
     357                mNumActiveViewCells = n; 
     358                mViewCells.clear(); 
     359                CollectViewCells(); 
     360        } 
     361 
     362        bool EqualToSpatialNode(ViewCell *viewCell) { return false;} // implemented in subclasses 
     363 
    361364 
    362365 
    363366protected: 
    364  
     367         
    365368 
    366369        /** 
     
    753756        void CollectMergeCandidates(const VssRayContainer &rays, vector<MergeCandidate> &candidates); 
    754757 
     758        bool EqualToSpatialNode(ViewCell *viewCell); 
     759 
    755760protected: 
     761 
     762        bool EqualToSpatialNode(ViewCell *viewCell, BspNode **node); 
    756763 
    757764        /** HACK 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r605 r607  
    116116        environment->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight); 
    117117 
     118        environment->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable); 
    118119 
    119120        mSubdivisionStats.open("subdivisionStats.log"); 
     
    431432 
    432433        mTotalCost = tData.mPvs * tData.mProbability / mBox.GetVolume(); 
    433  
     434        mTotalPvsSize = tData.mPvs; 
     435         
    434436        mSubdivisionStats  
    435437                        << "#ViewCells\n1\n" <<  endl 
    436438                        << "#RenderCostDecrease\n0\n" << endl  
    437                         << "#TotalRenderCost\n" << mTotalCost << endl; 
     439                        << "#TotalRenderCost\n" << mTotalCost << endl 
     440                        << "#AvgRenderCost\n" << mTotalPvsSize << endl; 
    438441 
    439442        Debug << "total cost: " << mTotalCost << endl; 
     
    533536                                float cData = tData.mPvs * tData.mProbability;; 
    534537 
    535                                 float costDecr =  
     538                float costDecr =  
    536539                                        (cFront + cBack - cData) / mBox.GetVolume(); 
     540 
     541                                int pvsFront = tFrontData.mPvs * tFrontData.mProbability; 
     542                                int pvsBack = tBackData.mPvs * tBackData.mProbability; 
     543                                int pvsData = tData.mPvs * tData.mProbability;; 
     544 
    537545                                mTotalCost += costDecr; 
     546                                mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; 
    538547 
    539548                                mSubdivisionStats  
    540549                                                << "#ViewCells\n" << mBspStats.Leaves() << endl 
    541550                                                << "#RenderCostDecrease\n" << -costDecr << endl  
    542                                                 << "#TotalRenderCost\n" << mTotalCost << endl; 
     551                                                << "#TotalRenderCost\n" << mTotalCost << endl 
     552                                                << "#AvgRenderCost\n" << mTotalPvsSize / mBspStats.Leaves() << endl; 
    543553                        } 
    544554 
     
    11111121        } 
    11121122 
     1123        // cost ratio miss 
     1124        if (!mUsePolygonSplitIfAvailable || data.mPolygons->empty()) 
     1125        { 
     1126                frontData.mIsKdNode = backData.mIsKdNode = false; 
     1127                if (lowestCost > mTermMaxCostRatio) 
     1128                        return false; 
     1129 
     1130                return true; 
     1131        } 
     1132 
    11131133        //-- evaluate axis aligned splits 
    11141134        int axis; 
     
    13611381 
    13621382                // only render cost heuristics or combined with standard deviation 
     1383                const float penaltyOld = EvalPvsPenalty(totalPvs, lowerPvsLimit, upperPvsLimit); 
     1384        const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
     1385                const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
     1386                         
     1387                const float oldRenderCost = pOverall * (float)penaltyOld + Limits::Small; 
     1388                const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
     1389 
     1390                float oldCost, newCost; 
     1391 
     1392                // only render cost 
    13631393                if (1) 
    13641394                { 
    1365                         const float penaltyOld = EvalPvsPenalty(totalPvs, lowerPvsLimit, upperPvsLimit); 
    1366                 const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
    1367                         const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
    1368                          
    1369                         const float oldRenderCost = pOverall * (float)penaltyOld + Limits::Small; 
    1370                         const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
    1371  
    1372                         float oldCost, newCost; 
    1373  
    1374                         // only render cost 
    1375                         if (1) 
    1376                         { 
    1377                                 oldCost = oldRenderCost; 
    1378                                 newCost = newRenderCost; 
    1379                         } 
    1380                         else // also considering standard deviation 
    1381                         { 
    1382                                 // standard deviation is difference of back and front pvs 
    1383                                 const float expectedCost = 0.5f * (penaltyFront + penaltyBack); 
    1384  
    1385                                 const float newDeviation = 0.5f *  
    1386                                         fabs(penaltyFront - expectedCost) + fabs(penaltyBack - expectedCost); 
    1387  
    1388                 const float oldDeviation = penaltyOld + Limits::Small; 
    1389  
    1390                                 newCost = mRenderCostWeight * newRenderCost + (1.0f - mRenderCostWeight) * newDeviation; 
    1391                                 oldCost = mRenderCostWeight * oldRenderCost + (1.0f - mRenderCostWeight) * oldDeviation; 
    1392                         } 
    1393  
    1394                         cost += mPvsFactor * newCost / oldCost; 
    1395                 } 
     1395                        oldCost = oldRenderCost; 
     1396                        newCost = newRenderCost; 
     1397                } 
     1398                else // also considering standard deviation 
     1399                { 
     1400                        // standard deviation is difference of back and front pvs 
     1401                        const float expectedCost = 0.5f * (penaltyFront + penaltyBack); 
     1402 
     1403                        const float newDeviation = 0.5f *  
     1404                                fabs(penaltyFront - expectedCost) + fabs(penaltyBack - expectedCost); 
     1405 
     1406                        const float oldDeviation = penaltyOld + Limits::Small; 
     1407 
     1408                        newCost = mRenderCostWeight * newRenderCost + (1.0f - mRenderCostWeight) * newDeviation; 
     1409                        oldCost = mRenderCostWeight * oldRenderCost + (1.0f - mRenderCostWeight) * oldDeviation; 
     1410                } 
     1411 
     1412                cost += mPvsFactor * newCost / oldCost; 
     1413                 
    13961414        } 
    13971415 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r605 r607  
    706706         
    707707        float mTotalCost; 
     708        int mTotalPvsSize; 
     709 
    708710        int mSplits; 
    709711 
     
    711713 
    712714        bool mUseRandomAxis; 
     715 
     716        bool mUsePolygonSplitIfAvailable; 
     717 
    713718private: 
    714719 
Note: See TracChangeset for help on using the changeset viewer.