Changeset 407 for trunk


Ignore:
Timestamp:
11/13/05 22:38:46 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h

    r372 r407  
    178178  /** \sa KdNode::IsLeaf() */ 
    179179  virtual bool IsLeaf() const { return true; } 
    180    
    181  
    182    
     180 
    183181 
    184182  /** pointers to occluders contained in this node */ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.cpp

    r406 r407  
    2727        Real renderTime = 0; 
    2828 
    29         // render time for 1 object of PVS 
    30         const float objRt = mObjRenderCost;  
    31          // const overhead for crossing a view cell border 
    32         const float vcOverhead = mVcOverhead; 
    33          
    3429        // total area of view cells 
    3530        float totalArea = 0;//= mKdTree->GetBox().SurfaceArea(); 
     
    4035 
    4136        ViewCellContainer::const_iterator it, it_end = viewCells.end(); 
    42          
     37 
     38        // surface area substitute for probability 
     39        PolygonContainer cell; 
     40 
    4341        for (it = viewCells.begin(); it != it_end; ++ it) 
    4442        { 
    45                 // surface area substitute for probability 
    46                 PolygonContainer cell; 
    47                 float area = 0; 
    48  
    4943                mBspTree->ConstructGeometry(dynamic_cast<BspViewCell *>(*it), cell); 
    50  
    51                 area = Polygon3::GetArea(cell); 
     44                CLEAR_CONTAINER(cell); 
     45                float area = Polygon3::GetArea(cell); 
    5246                 
    53                 renderTime += area * RenderPvs(*(*it), objRt) + vcOverhead; 
     47                renderTime += area * (RenderPvs(*(*it), mObjRenderCost) + mVcOverhead); 
    5448                totalArea += area; 
    55                 CLEAR_CONTAINER(cell); 
    5649        } 
    5750 
     
    6457} 
    6558 
    66 Real BspTreeRenderSimulator::RenderPvs(ViewCell &viewCell, float objRenderTime) const 
     59Real BspTreeRenderSimulator::RenderPvs(ViewCell &viewCell,  
     60                                                                           float objRenderTime) const 
    6761{ 
    6862        return viewCell.GetPvs().GetSize() * objRenderTime; 
    6963} 
    7064 
    71 /***************************************************** 
    72  *     class KdLeafRenderSimulator implementation    * 
    73  *****************************************************/ 
     65/******************************************************** 
     66 *     class KdLeafRenderSimulator implementation       * 
     67 *******************************************************/ 
    7468 
    7569KdTreeRenderSimulator::KdTreeRenderSimulator(float objRenderCost,  
     
    8276Real KdTreeRenderSimulator::SimulateRendering() 
    8377{ 
     78        //mKdTree->CollectLeavesPvs(); 
     79 
     80        // total render time 
    8481        Real renderTime = 0; 
     82        // overhead for loading a view cell 
     83        float loadOverhead = 0; 
    8584 
    86         // total area of view cells 
    87         float totalArea = 0;//= mKdTree->GetBox().SurfaceArea(); 
     85        // probability that view point lies in a view cell 
     86        float pInVcTotal = 0;//mKdTree->GetBox().GetVolume(); 
    8887 
    89         return renderTime; 
     88        // total probability that a view cell border is crossed 
     89        float pCrossVcTotal = 0; 
     90 
     91        vector<KdLeaf *> leaves; 
     92        mKdTree->CollectLeaves(leaves); 
     93         
     94        AxisAlignedBox3 box; 
     95 
     96        vector<KdLeaf *>::const_iterator it, it_end = leaves.end(); 
     97         
     98        for (it = leaves.begin(); it != it_end; ++ it) 
     99        { 
     100                box = mKdTree->GetBox(*it); 
     101                         
     102                // volume substitute for view point probability 
     103                float pInVc = 0; 
     104                 
     105                if (0) 
     106                        pInVc = box.GetVolume();  
     107                else 
     108                        pInVc = box.SurfaceArea(); 
     109                 
     110                // probability that a view cell border is crossed 
     111                const float pCrossVc = box.SurfaceArea(); 
     112 
     113                renderTime += pInVc * RenderPvs(*it, mObjRenderCost); 
     114                loadOverhead += pCrossVc * mVcOverhead; 
     115 
     116                pInVcTotal += pInVc; 
     117                pCrossVcTotal += pCrossVc; 
     118        } 
     119 
     120        renderTime /= pInVcTotal; 
     121        loadOverhead /= pCrossVcTotal; 
     122 
     123        return renderTime + loadOverhead; 
    90124} 
     125 
     126Real KdTreeRenderSimulator::RenderPvs(KdLeaf *leaf,  
     127                                                                                   float objRenderTime) const 
     128{ 
     129        return leaf->mKdPvs.GetSize() * objRenderTime; 
     130} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.h

    r406 r407  
    77class KdTree; 
    88class ViewCell; 
    9  
     9class KdLeaf; 
    1010 
    1111/** Simulated rendering using a simple render heuristics. Used to evaluate the  
     
    4747public: 
    4848        KdTreeRenderSimulator(float objRenderCost, float vcOverhead, KdTree *kdTree); 
    49  
    5049        Real SimulateRendering(); 
    5150 
    5251protected: 
     52 
     53        Real RenderPvs(KdLeaf *leaf, float objRenderTime) const; 
     54 
    5355        KdTree *mKdTree; 
    5456}; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r406 r407  
    537537         
    538538        if (ViewCell::sHierarchy == ViewCell::KD)        
    539                 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
     539                cout << "#totalKdPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    540540   
    541541        if (mBspTree) 
    542542        { 
    543543                //-- render simulation 
    544                 cout << "\nevaluating render time before merge ... "; 
     544                cout << "\nevaluating bsp view cells render time before merge ... "; 
    545545                Real rt = BspTreeRenderSimulator(mObjRenderCost, mVcOverhead, mBspTree).SimulateRendering(); 
    546546                 
     
    652652        if (1) { 
    653653         
     654        if (ViewCell::sHierarchy == ViewCell::KD) 
     655        { 
     656                cout << "\nevaluating kd view cells render time ... "; 
     657                Real rt = KdTreeRenderSimulator(mObjRenderCost, mVcOverhead, mKdTree).SimulateRendering(); 
     658                 
     659                cout << "avg render time: " << rt * 1e-3 << endl; 
     660                Debug << "avg render time: " << rt * 1e-3 << endl; 
     661        } 
     662 
    654663   for (int k=0; k < pvsOut; k++) { 
    655664                 Intersectable *object = objects[k]; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r406 r407  
    4848float BspTree::sPvsFactor = 1.0f; 
    4949 
     50bool BspTree::sStoreLeavesWithRays = false; 
    5051int BspNode::mailID = 1; 
    5152 
     
    284285                        ++ contributingSamples; 
    285286                } 
    286                 // warning: intersections not ordered 
    287                 ray->bspIntersections.push_back(Ray::BspIntersection((*it)->mMinT, this)); 
     287                if (BspTree::sStoreLeavesWithRays) 
     288                        // warning: intersections not ordered 
     289                        ray->bspIntersections.push_back(Ray::BspIntersection((*it)->mMinT, this)); 
    288290        } 
    289291} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r406 r407  
    794794        static int sTermMaxObjectsForAxisAligned; 
    795795 
     796        static bool sStoreLeavesWithRays; 
     797 
    796798        /// axis aligned split criteria 
    797799        static float sCt_div_ci; 
Note: See TracChangeset for help on using the changeset viewer.