Ignore:
Timestamp:
12/14/05 15:25:44 (19 years ago)
Author:
bittner
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
10 edited

Legend:

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

    r463 r464  
    15531553  RegisterOption("RssTree.splitType", optString, "split=", "queries"); 
    15541554  RegisterOption("RssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false"); 
    1555   RegisterOption("RssTree.useRss", optBool, "rss=", "false"); 
    15561555   
    15571556  RegisterOption("RssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000"); 
     
    15741573  RegisterOption("RssTree.dirSplitDepth", optInt, "dirsplidepth=", "10"); 
    15751574 
    1576  
     1575  RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs", "false"); 
     1576  RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree", "false"); 
     1577  RegisterOption("RssPreprocessor.Export.rays", optBool, "rss_export_rays", "false"); 
     1578  RegisterOption("RssPreprocessor.Export.numRays", optInt, "rss_export_num_rays=", "5000"); 
     1579  RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells", "false"); 
     1580  RegisterOption("RssPreprocessor.updateSubdivision", optBool, "rss_update_subdivision", "false"); 
     1581 
     1582   
    15771583  /************************************************************************************/ 
    15781584  /*               View space partition BSP tree related options                      */ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Makefile

    r463 r464  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.0-rc1) on: út 13. XII 21:49:08 2005 
     3# Generated by qmake (2.00a) (Qt 4.1.0-rc1) on: st 14. XII 10:37:40 2005 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r463 r464  
    1616static bool fromBoxVisibility = false; 
    1717 
    18 static bool exportPvs = false; 
    19 static bool exportRssTree = false; 
    20  
    21 static int numExportRays = 5000; 
    22 // static int numExportRays = 0; 
    23  
    24 static bool useViewcells = false; 
    2518 
    2619RssPreprocessor::RssPreprocessor(): 
     
    3528  environment->GetBoolValue("RssPreprocessor.useImportanceSampling", mUseImportanceSampling); 
    3629  environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 
    37          
     30 
     31  environment->GetBoolValue("RssPreprocessor.Export.pvs", mExportPvs); 
     32  environment->GetBoolValue("RssPreprocessor.Export.rssTree", mExportRssTree); 
     33  environment->GetBoolValue("RssPreprocessor.Export.rays", mExportRays); 
     34  environment->GetIntValue("RssPreprocessor.Export.numRays", mExportNumRays); 
     35  environment->GetBoolValue("RssPreprocessor.useViewcells", mUseViewcells); 
     36 
     37  environment->GetBoolValue("RssPreprocessor.updateSubdivision", mUpdateSubdivision); 
     38   
    3839  mStats.open("stats.log"); 
    3940} 
     
    130131                                                  pointA, 
    131132                                                  objectB, 
    132                                                   objectA); 
     133                                                  objectA, 
     134                                                  mPass 
     135                                                  ); 
    133136          vssRays.push_back(vssRay); 
    134137          hits ++; 
     
    139142                                                  pointB, 
    140143                                                  objectA, 
    141                                                   objectB); 
     144                                                  objectB, 
     145                                                  mPass 
     146                                                  ); 
    142147          vssRays.push_back(vssRay); 
    143148          hits ++; 
     
    385390RssPreprocessor::ComputeVisibility() 
    386391{ 
    387    
     392  cout<<"Rss Preprocessor started\n"<<flush; 
     393  cout<<"Memory/ray "<<sizeof(VssRay)+sizeof(RssTreeNode::RayInfo)<<endl; 
    388394  mSceneGraph->CollectObjects(&mObjects); 
    389395         
     
    487493   
    488494 
    489   if (numExportRays) { 
     495  if (mExportRays) { 
    490496        char filename[64]; 
    491497        sprintf(filename, "rss-rays-initial.x3d"); 
    492         ExportRays(filename, mVssRays, numExportRays); 
    493   } 
    494    
    495   if (useViewcells) 
     498        ExportRays(filename, mVssRays, mExportNumRays); 
     499  } 
     500   
     501  if (mUseViewcells) 
    496502        // construct view cells 
    497503        mViewCellsManager->Construct(mObjects, mVssRays, mViewSpaceBox); 
    498504 
    499505  rssTree = new RssTree; 
    500   // viewcells = Construct(mVssRays); 
    501506         
    502507  if (fromBoxVisibility) 
     
    507512  cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 
    508513 
    509   if (exportRssTree) { 
     514  if (mExportRssTree) { 
    510515        ExportRssTree("rss-tree-100.x3d", rssTree, Vector3(1,0,0)); 
    511516        ExportRssTree("rss-tree-001.x3d", rssTree, Vector3(0,0,1)); 
     
    515520  } 
    516521 
    517   if (exportPvs) { 
     522  if (mExportPvs) { 
    518523        ExportPvs("rss-pvs-initial.x3d", rssTree); 
    519524  } 
     
    522527  // get viewcells as kd tree boxes 
    523528  vector<AxisAlignedBox3> kdViewcells; 
     529 
    524530  if (0) { 
    525531        vector<KdLeaf *> leaves; 
     
    560566        rssTree->AddRays(vssRays); 
    561567                 
    562         if (1) { 
     568        if (mUpdateSubdivision) { 
    563569          int subdivided = rssTree->UpdateSubdivision(); 
    564570          cout<<"subdivided leafs = "<<subdivided<<endl; 
     
    567573        } 
    568574 
    569         if (useViewcells) { 
     575        if (mUseViewcells) { 
    570576          float avgPvs = GetAvgPvsSize(rssTree, kdViewcells); 
    571577          cout<<"Average PVS size = "<<avgPvs<<endl; 
    572578        } 
    573579 
    574         if (numExportRays) { 
     580        if (mExportRays) { 
    575581          char filename[64]; 
    576582          if (mUseImportanceSampling) 
     
    579585                sprintf(filename, "rss-rays-%04d.x3d", pass); 
    580586           
    581           ExportRays(filename, vssRays, numExportRays); 
     587          ExportRays(filename, vssRays, mExportNumRays); 
    582588        } 
    583589 
    584590        samples+=num; 
    585591 
    586         if (useViewcells) { 
     592        if (mUseViewcells) { 
    587593           
    588594          //-- prepare traversal rays for view cell intersections 
     
    625631        } 
    626632         
    627         if (exportPvs) { 
     633        if (mExportPvs) { 
    628634          char filename[64]; 
    629635          sprintf(filename, "rss-pvs-%04d.x3d", pass); 
     
    638644  } 
    639645   
    640   if (useViewcells) { 
     646  if (mUseViewcells) { 
    641647         
    642648        //-- post process view cells 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h

    r451 r464  
    2121  bool mUseImportanceSampling; 
    2222 
     23  bool mExportPvs; 
     24  bool mExportRssTree; 
     25  bool mExportRays; 
     26  int mExportNumRays; 
     27 
     28  bool mUseViewcells; 
     29  bool mUpdateSubdivision; 
     30   
    2331  AxisAlignedBox3 *mViewSpaceBox; 
    2432 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp

    r463 r464  
    121121  environment->GetBoolValue("RssTree.randomize", randomize); 
    122122  environment->GetBoolValue("RssTree.splitUseOnlyDrivingAxis", mSplitUseOnlyDrivingAxis); 
    123   environment->GetBoolValue("RssTree.useRss", mUseRss); 
    124123 
    125124  environment->GetBoolValue("RssTree.interleaveDirSplits", mInterleaveDirSplits); 
     
    292291  dirBBox.Initialize(); 
    293292 
    294   if (mUseRss) 
    295         forcedBoundingBox = NULL; 
    296293 
    297294  mForcedBoundingBox = forcedBoundingBox; 
     
    990987                   //                    (leaf->GetAvgRayContribution() > termMaxRayContribution ) || 
    991988                   (leaf->depth >= termMaxDepth) || 
    992                    (SqrMagnitude(GetBBox(leaf).Size()) <= termMinSize) || 
    993                    (mUseRss && leaf->mPassingRays == leaf->rays.size()) 
     989                   (SqrMagnitude(GetBBox(leaf).Size()) <= termMinSize)  
    994990                   ); 
    995991} 
     
    17691765 
    17701766void 
     1767RssTree::PickEdgeRays(RssTreeLeaf *leaf, 
     1768                                          int &r1, 
     1769                                          int &r2 
     1770                                          ) 
     1771{ 
     1772  int nrays = leaf->rays.size(); 
     1773 
     1774  if (nrays == 2) { 
     1775        r1 = 0; 
     1776        r2 = 1; 
     1777        return; 
     1778  } 
     1779   
     1780  int tries = min(20, nrays); 
     1781 
     1782  while (--tries) { 
     1783        r1 = Random(nrays); 
     1784        r2 = Random(nrays); 
     1785        if (leaf->rays[r1].mRay->mTerminationObject != leaf->rays[r2].mRay->mTerminationObject) 
     1786          break; 
     1787  } 
     1788 
     1789  if (r1 == r2) 
     1790        r2 = (r1+1)%leaf->rays.size(); 
     1791} 
     1792 
     1793 
     1794void 
    17711795RssTree::GenerateLeafRays(RssTreeLeaf *leaf, 
    17721796                                                  const int numberOfRays, 
     
    17761800  int nrays = leaf->rays.size(); 
    17771801  for (int i=0; i < numberOfRays; i++) { 
    1778         bool useExtendedConvexCombination = (nrays >= 3) && (i > numberOfRays/2); 
     1802        bool useExtendedConvexCombination = (nrays >= 2) && (i > numberOfRays/2); 
    17791803 
    17801804                 
     
    17831807        if (useExtendedConvexCombination) { 
    17841808          // pickup 3 random rays 
    1785           int r1 = Random(nrays); 
    1786           int r2 = Random(nrays); 
    1787           int r3 = Random(nrays); 
     1809          int r1, r2; 
     1810          PickEdgeRays(leaf, r1, r2); 
    17881811           
    17891812          Vector3 o1 = leaf->rays[r1].GetOrigin(); 
    1790            
    17911813          Vector3 o2 = leaf->rays[r2].GetOrigin(); 
    17921814           
    1793           Vector3 o3 = leaf->rays[r3].GetOrigin(); 
    1794            
    1795           const float overlap = 0.0; 
    1796            
    1797  
    1798           float w1, w2, w3; 
    1799           GenerateExtendedConvexCombinationWeights(w1, w2, w3, overlap); 
    1800           origin = w1*o1 + w2*o2 + w3*o3; 
     1815          const float overlap = 0.1f; 
     1816          float w1, w2; 
     1817          GenerateExtendedConvexCombinationWeights2(w1, w2, overlap); 
     1818          origin = w1*o1 + w2*o2; 
    18011819          direction = 
    18021820                w1*leaf->rays[r1].mRay->GetDir() + 
    1803                 w2*leaf->rays[r2].mRay->GetDir() + 
    1804                 w3*leaf->rays[r3].mRay->GetDir(); 
     1821                w2*leaf->rays[r2].mRay->GetDir(); 
    18051822          // shift the origin a little bit 
    18061823          origin += direction*0.1f; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.h

    r463 r464  
    553553  bool mSplitUseOnlyDrivingAxis; 
    554554   
    555   // use ray space subdivision instead of view space subdivision 
    556   bool mUseRss; 
    557555 
    558556  // interleave directional and spatial splits based on their costs 
     
    853851 
    854852 
     853  void 
     854  PickEdgeRays(RssTreeLeaf *leaf, 
     855                           int &r1, 
     856                           int &r2 
     857                           ); 
     858 
    855859}; 
    856860 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.cpp

    r459 r464  
    158158 
    159159void 
     160GenerateExtendedConvexCombinationWeights2(float &w1, 
     161                                                                                  float &w2, 
     162                                                                                  const float overlap 
     163                                                                                  ) 
     164{ 
     165  w1 = RandomValue(-overlap, 1.0f + overlap); 
     166  w2 = 1.0f - w1; 
     167} 
     168 
     169void 
    160170GenerateExtendedConvexCombinationWeights(float &w1, 
    161171                                                                                 float &w2, 
     
    164174                                                                                 ) 
    165175{ 
    166   w1 = RandomValue(-overlap, 1.0f + overlap); 
    167   w2 = RandomValue(-overlap, 1.0f + overlap); 
    168   w3 = 1.0f - w1 - w2; 
     176 
     177  while (1) { 
     178        w1 = RandomValue(-overlap, 1.0f + overlap); 
     179        w2 = RandomValue(-overlap, 1.0f + overlap); 
     180        w3 = 1.0f + overlap - w1 - w2; 
     181        if (w3 >= -overlap && w3 <= 1.0f + overlap) 
     182          break; 
     183        /* 
     184        w3 = RandomValue(0.0f, 1.0f + overlap); 
     185         
     186        float sum = w1 + w2 + w3; 
     187        if (sum>0.0f) { 
     188          w1/=sum; 
     189          w2/=sum; 
     190          w3/=sum; 
     191          break; 
     192        } 
     193        */ 
     194  } 
    169195} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h

    r463 r464  
    4444  Intersectable *mOriginObject; 
    4545  Intersectable *mTerminationObject; 
    46          
     46 
     47  //////////////////////// 
     48  // members related to importance sampling 
     49  // sampling pass in which this ray was generated 
     50  short mPass; 
     51 
     52  // number of cells where this ray made a contribution to the PVS 
     53  short mPvsContribution; 
     54   
     55  // sum of relative ray contributions per object 
     56  float mRelativePvsContribution; 
     57   
    4758  ////////////////////////////// 
    48   VssRay(const Vector3 &origin, 
     59  VssRay( 
     60                 const Vector3 &origin, 
    4961                 const Vector3 &termination, 
    5062                 Intersectable *originObject, 
    51                  Intersectable *terminationObject): 
     63                 Intersectable *terminationObject, 
     64                 const int pass = 0 
     65                 ): 
    5266        mMailbox(-1), 
    5367    mOrigin(origin), 
     
    5670        mTerminationObject(terminationObject), 
    5771        mRefCount(0), 
    58     mFlags(0) 
     72    mFlags(0), 
     73        mPass(pass) 
    5974        //      mT(1.0f) 
    6075  { 
     
    6681        mFlags(0), 
    6782        mMailbox(-1), 
    68         mOriginObject(ray.sourceObject.mObject) 
     83        mOriginObject(ray.sourceObject.mObject), 
     84        mPass(0) 
    6985        //      mT(1.0f) 
    7086        { 
     
    223239                                                                                 ); 
    224240 
     241void 
     242GenerateExtendedConvexCombinationWeights2(float &w1, 
     243                                                                                  float &w2, 
     244                                                                                  const float overlap 
     245                                                                                  ); 
     246 
    225247// -------------------------------------------------------------- 
    226248// For sorting rays 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r463 r464  
    6565        samplesPerPass  100000 
    6666        initialSamples 500000 
    67         vssSamples 50000000 
     67        vssSamples 10000000 
    6868        vssSamplesPerPass 500000 
    6969        useImportanceSampling true 
     70 
     71        Export { 
     72                pvs false 
     73                rssTree false 
     74                rays true 
     75                numRays 5000 
     76        } 
     77 
     78        useViewcells false 
     79        updateSubdivision false 
    7080} 
    7181 
    7282RssTree { 
    73         useRss    false 
     83 
    7484        epsilon         1e-6 
    7585 
  • trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp

    r450 r464  
    2626    
    2727  char buff[128]; 
    28    
    2928  environment->GetStringValue("Preprocessor.type", buff); 
    3029  string preprocessorType(buff); 
     
    3231  Preprocessor *p; 
    3332 
    34         if (preprocessorType == "vss") 
    35                 p = new VssPreprocessor(); 
     33  if (preprocessorType == "vss") 
     34        p = new VssPreprocessor(); 
     35  else 
     36        if (preprocessorType == "rss") 
     37          p = new RssPreprocessor(); 
    3638        else 
    37           if (preprocessorType == "rss") 
    38                 p = new RssPreprocessor(); 
     39          if (preprocessorType == "exact") 
     40                p = new ExactPreprocessor(); 
    3941          else 
    40                 if (preprocessorType == "exact") 
    41                   p = new ExactPreprocessor(); 
    42                 else 
    43                   if (preprocessorType == "sampling") 
    44                                 p = new SamplingPreprocessor(); 
    45                   else { 
    46                         cerr<<"Unknown preprocessor type"<<endl; 
    47                         Debug<<"Unknown preprocessor type"<<endl; 
    48                         exit(1); 
    49                   } 
    50          
    51          
     42                if (preprocessorType == "sampling") 
     43                  p = new SamplingPreprocessor(); 
     44                else { 
     45                  cerr<<"Unknown preprocessor type"<<endl; 
     46                  Debug<<"Unknown preprocessor type"<<endl; 
     47                  exit(1); 
     48                } 
     49   
     50   
    5251        environment->GetStringValue("Scene.filename", buff); 
    5352        string filename(buff); 
Note: See TracChangeset for help on using the changeset viewer.