Changeset 467


Ignore:
Timestamp:
12/15/05 15:18:15 (18 years ago)
Author:
bittner
Message:

rsstree statistics

Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r466 r467  
    1212#include "RenderSimulator.h" 
    1313 
    14 static bool useViewSpaceBox = true; 
     14static bool useViewSpaceBox = false; 
    1515static bool use2dSampling = false; 
    1616static bool fromBoxVisibility = false; 
     
    219219   
    220220  cout<< 
    221         "#AVG_PVS_SIZE\n"<<avgPvsSize<<endl<< 
    222         "#AVG_RAYS\n"<<avgRays<<endl<< 
    223         "#AVG_RAY_CONTRIB\n"<<avgRayContribution<<endl<< 
    224         "#AVG_PVS_ENTROPY\n"<<avgPvsEntropy<<endl<< 
    225         "#AVG_RAY_LENGTH_ENTROPY\n"<<avgRayLengthEntropy<<endl<< 
    226         "#AVG_IMPORTANCE\n"<<avgImportance<<endl; 
     221        "#RSS_AVG_PVS_SIZE\n"<<avgPvsSize<<endl<< 
     222        "#RSS_AVG_RAYS\n"<<avgRays<<endl<< 
     223        "#RSS_AVG_RAY_CONTRIB\n"<<avgRayContribution<<endl<< 
     224        "#RSS_AVG_PVS_ENTROPY\n"<<avgPvsEntropy<<endl<< 
     225        "#RSS_AVG_RAY_LENGTH_ENTROPY\n"<<avgRayLengthEntropy<<endl<< 
     226        "#RSS_AVG_IMPORTANCE\n"<<avgImportance<<endl; 
    227227   
    228228  if (0) { 
     
    466466        } 
    467467     
    468         mPass++; 
    469                  
    470         int pvsSize = 0; 
     468                 
    471469        float avgRayContrib = (passContributingSamples > 0) ?  
    472470          passSampleContributions/(float)passContributingSamples : 0; 
     
    475473        cout << "#TotalSamples=" << totalSamples/1000  
    476474                 << "k   #SampleContributions=" << passSampleContributions << " ("  
    477                  << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 
    478                  << pvsSize/(float)mObjects.size() << endl  
    479                  << "avg ray contrib=" << avgRayContrib << endl; 
     475                 << 100*passContributingSamples/(float)passSamples<<"%)"  
     476                 << "avgcontrib=" << avgRayContrib << endl; 
    480477                 
    481478        mStats << 
     
    485482          "#SampleContributions\n" << passSampleContributions << endl <<  
    486483          "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl << 
    487           "#AvgPVS\n"<< pvsSize/(float)mObjects.size() << endl << 
    488484          "#AvgRayContrib\n" << avgRayContrib << endl; 
     485         
     486        mPass++; 
     487 
    489488  } 
    490489   
     
    499498  } 
    500499   
    501   if (mUseViewcells) 
     500  if (mUseViewcells) { 
    502501        // construct view cells 
    503502        mViewCellsManager->Construct(mObjects, mVssRays, mViewSpaceBox); 
     503         
     504        VssRayContainer selectedRays; 
     505        int desired = Max( 
     506                                          mViewCellsManager->GetPostProcessSamples(), 
     507                                          mViewCellsManager->GetVisualizationSamples()); 
     508        float p = desired/(float)mVssRays.size(); 
     509        //      rssTree->CollectRays(storedRays, desired); 
     510        for (int i=0; i < mVssRays.size(); i++) { 
     511          if (Random(1.0f) < p) 
     512                selectedRays.push_back(mVssRays[i]); 
     513        } 
     514        //-- post process view cells 
     515        mViewCellsManager->PostProcess(mObjects, selectedRays); 
     516         
     517        //-- several visualizations and statistics 
     518        mViewCellsManager->PrintStatistics(Debug); 
     519         
     520        if (1)  
     521          mViewCellsManager->Visualize(mObjects, selectedRays); 
     522 
     523        CLEAR_CONTAINER(storedRays); 
     524  } 
     525 
    504526 
    505527  rssTree = new RssTree; 
    506528         
    507   if (fromBoxVisibility) 
    508         rssTree->Construct(mVssRays, mViewSpaceBox); 
    509   else 
    510         rssTree->Construct(mVssRays, NULL); 
    511  
    512   cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 
    513  
    514   if (mExportRssTree) { 
    515         ExportRssTree("rss-tree-100.x3d", rssTree, Vector3(1,0,0)); 
    516         ExportRssTree("rss-tree-001.x3d", rssTree, Vector3(0,0,1)); 
    517         ExportRssTree("rss-tree-101.x3d", rssTree, Vector3(1,0,1)); 
    518         ExportRssTree("rss-tree-101m.x3d", rssTree, Vector3(-1,0,-1)); 
    519         ExportRssTreeLeaves(rssTree, 10); 
    520   } 
    521  
    522   if (mExportPvs) { 
    523         ExportPvs("rss-pvs-initial.x3d", rssTree); 
    524   } 
    525  
     529  if (mUseImportanceSampling) { 
     530         
     531        if (fromBoxVisibility) 
     532          rssTree->Construct(mVssRays, mViewSpaceBox); 
     533        else 
     534          rssTree->Construct(mVssRays, NULL); 
     535        cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 
     536         
     537        if (mExportRssTree) { 
     538          ExportRssTree("rss-tree-100.x3d", rssTree, Vector3(1,0,0)); 
     539          ExportRssTree("rss-tree-001.x3d", rssTree, Vector3(0,0,1)); 
     540          ExportRssTree("rss-tree-101.x3d", rssTree, Vector3(1,0,1)); 
     541          ExportRssTree("rss-tree-101m.x3d", rssTree, Vector3(-1,0,-1)); 
     542          ExportRssTreeLeaves(rssTree, 10); 
     543        } 
     544         
     545        if (mExportPvs) { 
     546          ExportPvs("rss-pvs-initial.x3d", rssTree); 
     547        } 
     548  } 
     549   
    526550  // viewcells->UpdatePVS(newVssRays); 
    527551   
    528   int samples = 0; 
    529   int pass = 0; 
     552  int rssPass = 0; 
     553  int rssSamples = 0; 
    530554  while (1) { 
    531555        int num = mRssSamplesPerPass; 
     
    546570        for (int i=0; i < rays.size(); i++) 
    547571          CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays); 
    548          
     572 
     573         
     574        totalSamples+=num; 
     575        rssSamples+=num; 
     576 
     577        mStats << 
     578          "#Pass\n" <<mPass<<endl<< 
     579          "#RssPass\n" <<rssPass<<endl<< 
     580          "#Time\n" << TimeDiff(startTime, GetTime())*1e-3<<endl<< 
     581          "#TotalSamples\n" <<totalSamples<<endl<< 
     582          "#RssSamples\n" <<rssSamples<<endl; 
     583 
    549584        if (mUseViewcells) { 
    550585           
     586          /// compute view cell contribution of rays 
     587          mViewCellsManager->ComputeSampleContributions(vssRays); 
    551588           
    552           /// compute view cell contribution of rays 
    553           mViewCellsManager->ComputeSampleContributions(vssRays 
    554                                                                                                         ); 
     589          vssRays.PrintStatistics(mStats); 
     590          mViewCellsManager->PrintPvsStatistics(mStats); 
     591        } 
     592 
     593        // add rays to the tree after the viewcells have been cast to have their contributions 
     594        // already when adding into the tree 
     595        // do not add those rays which have too low or no contribution.... 
     596         
     597        if (mUseImportanceSampling) { 
     598          rssTree->AddRays(vssRays); 
    555599           
     600          if (0) { 
     601                cout<<"############# Rss PVS STAT ##################\n"; 
     602                cout<<"#AVG_RSS_PVS\n"<<rssTree->GetAvgPvsSize()<<endl; 
     603                cout<<"#RSS_ROOT_PVS\n"<<rssTree->GetRootPvsSize()<<endl; 
     604          } 
    556605           
    557           float pvs = rssTree->GetAvgPvsSize(); 
    558           cout<<"*****************************\n"; 
    559           cout<<samples<<" avgPVS ="<<pvs<<endl; 
    560           cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 
    561           cout<<"*****************************\n"; 
    562         } 
    563  
    564  
    565  
    566         rssTree->AddRays(vssRays); 
    567          
    568         if (mUpdateSubdivision) { 
    569           int subdivided = rssTree->UpdateSubdivision(); 
    570           cout<<"subdivided leafs = "<<subdivided<<endl; 
    571           cout<<"#total leaves = "<<rssTree->stat.Leaves()<<endl; 
    572         } 
    573  
    574         if (mUseViewcells) { 
    575           //      float avgPvs = GetAvgPvsSize(rssTree, kdViewcells); 
    576           //      cout<<"Average PVS size = "<<avgPvs<<endl; 
    577         } 
    578  
     606          if (mUpdateSubdivision) { 
     607                int subdivided = rssTree->UpdateSubdivision(); 
     608                cout<<"subdivided leafs = "<<subdivided<<endl; 
     609                cout<<"#total leaves = "<<rssTree->stat.Leaves()<<endl; 
     610          } 
     611        } 
     612         
    579613        if (mExportRays) { 
    580614          char filename[64]; 
    581615          if (mUseImportanceSampling) 
    582                 sprintf(filename, "rss-rays-i%04d.x3d", pass); 
     616                sprintf(filename, "rss-rays-i%04d.x3d", rssPass); 
    583617          else 
    584                 sprintf(filename, "rss-rays-%04d.x3d", pass); 
     618                sprintf(filename, "rss-rays-%04d.x3d", rssPass); 
    585619           
    586620          ExportRays(filename, vssRays, mExportNumRays); 
    587621        } 
    588622 
    589         samples+=num; 
    590  
    591623         
    592624        if (mExportPvs) { 
    593625          char filename[64]; 
    594           sprintf(filename, "rss-pvs-%04d.x3d", pass); 
     626          sprintf(filename, "rss-pvs-%04d.x3d", rssPass); 
    595627          ExportPvs(filename, rssTree); 
    596628        } 
    597629 
    598         if (samples >= mRssSamples) 
     630        if (totalSamples >= mRssSamples + mInitialSamples) 
    599631          break; 
    600632 
    601633         
    602         pass++; 
     634        rssPass++; 
     635        mPass++; 
    603636  } 
    604637   
    605638  if (mUseViewcells) { 
    606639 
    607         VssRayContainer storedRays; 
    608         rssTree->CollectRays(storedRays, Max( 
    609                                                                                  mViewCellsManager->GetPostProcessSamples(), 
    610                                                                                  mViewCellsManager->GetVisualizationSamples())); 
    611          
    612         //-- post process view cells 
    613         mViewCellsManager->PostProcess(mObjects, storedRays); 
    614          
    615         //-- several visualizations and statistics 
    616         mViewCellsManager->PrintStatistics(Debug); 
    617  
    618         mViewCellsManager->Visualize(mObjects, storedRays); 
    619  
    620         CLEAR_CONTAINER(storedRays); 
    621640 
    622641  //-- render simulation after merge 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r466 r467  
    208208} 
    209209 
     210void 
     211ViewCellsManager::GetPvsStatistics(PvsStatistics &stat) 
     212{ 
     213  ViewCellContainer::const_iterator it = mViewCells.begin(); 
     214  stat.viewcells = 0; 
     215  stat.minPvs = 100000000; 
     216  stat.maxPvs = 0; 
     217  stat.avgPvs = 0.0f; 
     218 
     219  for (; it != mViewCells.end(); ++it) { 
     220        ViewCell *viewcell = *it; 
     221        int pvsSize = viewcell->GetPvs().GetSize(); 
     222        if ( pvsSize < stat.minPvs) 
     223          stat.minPvs = pvsSize; 
     224        if (pvsSize > stat.maxPvs) 
     225          stat.maxPvs = pvsSize; 
     226        stat.avgPvs += pvsSize; 
     227        stat.viewcells++; 
     228  } 
     229  if (stat.viewcells) 
     230        stat.avgPvs/=stat.viewcells; 
     231} 
     232 
     233void 
     234ViewCellsManager::PrintPvsStatistics(ostream &s) 
     235{ 
     236  s<<"############# Viewcell PVS STAT ##################\n"; 
     237  PvsStatistics pvsStat; 
     238  GetPvsStatistics(pvsStat); 
     239  s<<"#AVG_PVS\n"<<pvsStat.avgPvs<<endl; 
     240  s<<"#MAX_PVS\n"<<pvsStat.maxPvs<<endl; 
     241  s<<"#MIN_PVS\n"<<pvsStat.minPvs<<endl; 
     242} 
     243 
    210244/**********************************************************************/ 
    211245/*                   BspViewCellsManager implementation               */ 
     
    260294                sampleRays.push_back(new Ray(*rays[i])); 
    261295 
    262         if (mViewCells.empty()) // no view cells loaded 
    263                 mBspTree->Construct(objects, sampleRays); 
    264         else 
    265                 mBspTree->Construct(mViewCells); 
    266  
     296        if (mViewCells.empty()) { // no view cells loaded  
     297          mBspTree->Construct(objects, sampleRays); 
     298          mBspTree->CollectViewCells(mViewCells); 
     299        } else 
     300          mBspTree->Construct(mViewCells); 
     301         
     302         
    267303        Debug << mBspTree->GetStatistics() << endl; 
    268304         
     
    280316                                  viewcells 
    281317                                  ); 
     318 
     319  ray.mPvsContribution = 0; 
     320  ray.mRelativePvsContribution = 0.0f; 
    282321   
    283322  ViewCellContainer::const_iterator it = viewcells.begin(); 
     
    770809} 
    771810 
     811 
    772812/**********************************************************************/ 
    773813/*                   KdViewCellsManager implementation               */ 
     
    11861226 
    11871227        mVspBspTree->Construct(sampleRays); 
     1228        mVspBspTree->CollectViewCells(mViewCells); 
    11881229         
    11891230        Debug << mVspBspTree->GetStatistics() << endl; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r466 r467  
    2929 
    3030public: 
     31  struct PvsStatistics { 
     32        int minPvs; 
     33        int maxPvs; 
     34        float avgPvs; 
     35        int viewcells; 
     36  }; 
    3137   
    3238  /// view cell container types 
     
    165171                                                          ) = 0; 
    166172 
     173  virtual void GetPvsStatistics(PvsStatistics &stat); 
     174 
     175  virtual void 
     176  PrintPvsStatistics(ostream &s); 
    167177 
    168178protected: 
     
    183193 
    184194        /// Loaded view cells 
    185         ViewCellContainer mViewCells; 
     195  ViewCellContainer mViewCells; 
    186196 
    187197        /// maximum number of samples taken for construction of the view cells 
     
    234244                                          ); 
    235245 
     246   
    236247protected: 
    237248 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.cpp

    r464 r467  
    194194  } 
    195195} 
     196 
     197 
     198void 
     199VssRayContainer::PrintStatistics(ostream &s) 
     200{ 
     201 
     202  VssRayContainer::const_iterator it = begin(), it_end = end(); 
     203  int sumContributions = 0; 
     204  float sumRelContributions = 0.0f; 
     205   
     206  for (; it != it_end; ++it) { 
     207        VssRay *ray = *it; 
     208        sumContributions += ray->mPvsContribution; 
     209        sumRelContributions += ray->mRelativePvsContribution; 
     210  } 
     211   
     212  s<<"##### VSS RAY STAT ##########\n"; 
     213  s<<"#RAYS\n"<<size()<<endl; 
     214  s<<"#AVG_RAY_PVS_CONTRIBUTION\n"<<sumContributions/(float)size()<<endl; 
     215  s<<"#AVG_RAY_RELATIVE_PVS_CONTRIBUTION\n"<<sumRelContributions/ 
     216        (float)size()<<endl; 
     217   
     218} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h

    r464 r467  
    269269}; 
    270270 
    271 typedef  vector<VssRay *> VssRayContainer; 
     271struct VssRayContainer : public vector<VssRay *> 
     272{ 
     273  void PrintStatistics(ostream &s); 
     274}; 
    272275 
    273276 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r464 r467  
    6666        initialSamples 500000 
    6767        vssSamples 10000000 
    68         vssSamplesPerPass 500000 
     68        vssSamplesPerPass 100000 
    6969        useImportanceSampling true 
    7070 
     
    7676        } 
    7777 
    78         useViewcells false 
     78        useViewcells true 
    7979        updateSubdivision false 
    8080} 
     
    156156        loadFromFile false 
    157157        #type kdTree 
    158         type vspKdTree 
     158        #type vspKdTree 
    159159        #type bspTree 
    160         #type vspBspTree 
     160        type vspBspTree 
    161161         
    162162        #type sceneDependent 
     
    339339        Termination { 
    340340                # parameters used for autopartition 
    341                 minRays 200 
     341                minRays 1000 
    342342                minPolygons -1 
    343343                maxDepth 40 
    344                 minPvs 100 
    345                 minArea 0.01 
     344                minPvs 20 
     345                minArea 200000 
    346346                maxRayContribution 0.005 
    347347                #maxAccRayLength 100 
Note: See TracChangeset for help on using the changeset viewer.