Changeset 1737 for GTP/trunk/Lib


Ignore:
Timestamp:
11/09/06 19:41:31 (18 years ago)
Author:
bittner
Message:

visibility filter updates

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1736 r1737  
    24212421void BvHierarchy::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
    24222422{ 
    2423         stack<BvhNode *> nodeStack; 
    2424  
    2425         nodeStack.push(mRoot); 
    2426  
    2427         while (!nodeStack.empty())  
    2428         { 
    2429                 BvhNode *node = nodeStack.top(); 
    2430  
    2431                 nodeStack.pop(); 
    2432  
    2433                 if (node->IsLeaf())  
    2434                 { 
    2435                         BvhLeaf *leaf = (BvhLeaf *)node; 
    2436  
    2437                         ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
    2438  
    2439                         for (oit = leaf->mObjects.begin(); oit != oit_end; ++oit)  
    2440                         { 
    2441                                 Intersectable *object = *oit; 
    2442                                 if (Overlap(box, object->GetBox()))  
    2443                                 { 
    2444                                         object->Mail(); 
    2445                                         objects.push_back(object); 
    2446                                 } 
     2423  stack<BvhNode *> nodeStack; 
     2424 
     2425  nodeStack.push(mRoot); 
     2426 
     2427  while (!nodeStack.empty())  
     2428        { 
     2429          BvhNode *node = nodeStack.top(); 
     2430           
     2431          nodeStack.pop(); 
     2432           
     2433          if (node->IsLeaf())  
     2434                { 
     2435                  BvhLeaf *leaf = (BvhLeaf *)node; 
     2436                  if (Overlap(box, leaf->GetBoundingBox())) { 
     2437                        Intersectable *object = GetOrCreateBvhIntersectable(leaf); 
     2438                        if (!object->Mailed()) { 
     2439                          object->Mail(); 
     2440                          objects.push_back(object); 
    24472441                        } 
     2442                  } 
    24482443                }  
    2449                 else  
    2450                 { 
    2451                         BvhInterior *interior = (BvhInterior *)node; 
    2452  
    2453                         if (Overlap(box, interior->GetBoundingBox())) 
    2454                                 nodeStack.push(interior->GetFront()); 
    2455  
    2456                         if (Overlap(box, interior->GetBoundingBox())) 
    2457                                 nodeStack.push(interior->GetBack()); 
    2458                 } 
    2459         } 
    2460 } 
    2461  
    2462 } 
     2444          else  
     2445                { 
     2446                  BvhInterior *interior = (BvhInterior *)node; 
     2447                   
     2448                  if (Overlap(box, interior->GetBoundingBox())) 
     2449                        nodeStack.push(interior->GetFront()); 
     2450                   
     2451                  if (Overlap(box, interior->GetBoundingBox())) 
     2452                        nodeStack.push(interior->GetBack()); 
     2453                } 
     2454        } 
     2455} 
     2456 
     2457} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r1608 r1737  
    176176  glEnd(); 
    177177} 
     178 
     179 
    178180 
    179181void 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp

    r1694 r1737  
    33#include "Triangle3.h" 
    44#include "KdTree.h" 
     5#include "BvHierarchy.h" 
    56 
    67 
     
    9798} 
    9899 
     100AxisAlignedBox3 BvhIntersectable::GetBox() const 
     101{ 
     102  return mItem->GetBoundingBox(); 
    99103} 
     104 
     105} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r1707 r1737  
    179179                return Intersectable::BVH_INTERSECTABLE; 
    180180        } 
     181 
     182        AxisAlignedBox3 GetBox() const; 
     183 
    181184}; 
    182185 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r1715 r1737  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: st 1. XI 14:21:30 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 9. XI 13:27:58 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1736 r1737  
    298298template <typename T, typename S> void Pvs<T, S>::Merge(const Pvs<T, S> &a) 
    299299{ 
    300         std::map<T, S, LtSample<T> >::const_iterator it; 
    301  
    302         for (it = a.mEntries.begin(); it != a.mEntries.end(); ++ it) 
    303         { 
    304                 AddSample((*it).first, (*it).second.mSumPdf); 
    305         } 
     300   
     301  std::map<T, S, LtSample<T> >::const_iterator it; 
     302  int samples = mSamples + a.mSamples; 
     303 
     304  for (it = a.mEntries.begin(); it != a.mEntries.end(); ++ it) 
     305        { 
     306          AddSample((*it).first, (*it).second.mSumPdf); 
     307        } 
     308  mSamples = samples; 
    306309} 
    307310 
     
    446449int Pvs<T, S>::AddPvs(const Pvs<T, S> &pvs) 
    447450{ 
    448   mSamples += pvs.mSamples; 
     451  int samples = mSamples + pvs.mSamples; 
    449452  std::map<T, S, LtSample<T> >:: 
    450453        const_iterator it, it_end = pvs.mEntries.end(); 
     
    456459          AddSample((*it).first, (*it).second.mSumPdf, contri); 
    457460  } 
    458    
     461 
     462  mSamples = samples; 
     463 
    459464  return GetSize(); 
    460465} 
     
    463468int Pvs<T, S>::SubtractPvs(const Pvs<T, S> &pvs) 
    464469{ 
    465   mSamples -= pvs.mSamples; 
     470   
     471  int samples = mSamples - pvs.mSamples; 
    466472  std::map<T, S, LtSample<T> >:: 
    467473        const_iterator it, it_end = pvs.mEntries.end(); 
     
    470476  for (it = pvs.mEntries.begin(); it != it_end; ++ it)  
    471477        RemoveSample((*it).first, (*it).second.mSumPdf); 
    472    
     478 
     479  mSamples = samples; 
    473480  return GetSize(); 
    474481} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp

    r1715 r1737  
    947947} 
    948948 
     949 
    949950void 
    950951QtGlRendererWidget::RenderPvs() 
     
    970971 
    971972        if (mUseSpatialFilter) { 
     973          // 9.11. 2006 -> experiment with new spatial filter 
     974#if 0 
    972975          mViewCellsManager->ApplySpatialFilter(mKdTree, 
    973976                                                                                        mSpatialFilterSize* 
    974977                                                                                        Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 
    975978                                                                                        pvs); 
     979#else 
     980          // mSpatialFilter size is in range 0.001 - 0.1 
     981          mViewCellsManager->ApplyFilter2(viewcell, 
     982                                                                          mUseFilter, 
     983                                                                          100*mSpatialFilterSize, 
     984                                                                          pvs); 
     985#endif 
    976986        } 
    977987         
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1723 r1737  
    366366 
    367367void 
    368 NormalizeRatios(float ratios[3]) 
     368NormalizeRatios(float ratios[4]) 
    369369{ 
    370370  int i; 
    371371  float sumRatios; 
    372   sumRatios = ratios[0] + ratios[1] + ratios[2]; 
     372  sumRatios = ratios[0] + ratios[1] + ratios[2] + ratios[3]; 
    373373  if (sumRatios == 0.0f) { 
    374374        ratios[0] = ratios[1] = ratios[2] = 1.0f; 
    375         sumRatios = 3.0f; 
    376   } 
    377    
    378   for (i=0 ; i < 3; i++) 
     375        sumRatios = 4.0f; 
     376  } 
     377   
     378  for (i=0 ; i < 4; i++) 
    379379        ratios[i]/=sumRatios; 
    380380 
     
    387387#endif 
    388388   
    389   for (; i < 3; i++) 
     389  for (; i < 4; i++) 
    390390        if (ratios[i] < MIN_RATIO) 
    391391          ratios[i] = MIN_RATIO; 
    392392 
    393   sumRatios = ratios[0] + ratios[1] + ratios[2]; 
    394   for (i=0 ; i < 3; i++) 
     393  sumRatios = ratios[0] + ratios[1] + ratios[2] + ratios[3]; 
     394  for (i=0 ; i < 4; i++) 
    395395        ratios[i]/=sumRatios; 
    396396   
     
    432432  int rssPass = 0; 
    433433  int rssSamples = 0; 
     434 
     435  mDistributions.push_back(SamplingDistribution(SamplingStrategy::RSS_BASED_DISTRIBUTION)); 
     436  mDistributions.push_back(SamplingDistribution(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION)); 
     437  mDistributions.push_back(SamplingDistribution(SamplingStrategy::DIRECTION_BASED_DISTRIBUTION)); 
     438  mDistributions.push_back(SamplingDistribution(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION)); 
    434439   
    435440  if (mLoadInitialSamples) { 
     
    439444  } else { 
    440445        SimpleRayContainer rays; 
    441  
     446         
    442447        cout<<"Generating initial rays..."<<endl<<flush; 
    443  
     448         
    444449        if (mUseImportanceSampling) { 
    445           GenerateRays(mInitialSamples/2, SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
     450          GenerateRays(mInitialSamples/3, SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
    446451          //      GenerateRays(mInitialSamples/3, SamplingStrategy::OBJECT_BASED_DISTRIBUTION, rays); 
    447           GenerateRays(mInitialSamples/2, SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, rays); 
     452          GenerateRays(mInitialSamples/3, SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, rays); 
     453          GenerateRays(mInitialSamples/3, SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION, rays); 
    448454          //    GenerateRays(mInitialSamples/4, OBJECT_DIRECTION_BASED_DISTRIBUTION, rays); 
     455           
     456 
    449457        } else { 
    450                 int rayType = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 
     458          int rayType = SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION; 
    451459          if (mObjectBasedSampling) 
    452460                rayType = SamplingStrategy::OBJECT_BASED_DISTRIBUTION; 
     
    578586 
    579587#if USE_RSS_TREE         
    580           static float ratios[] = {0.9f,0.05f,0.05f}; 
     588          static float ratios[] = {0.9f,0.05f,0.05f,0.05f}; 
    581589#else 
    582           static float ratios[] = {0.0f,0.05f,0.05f}; 
     590          static float ratios[] = {0.0f,0.05f,0.05f,0.05f}; 
    583591#endif 
    584592          NormalizeRatios(ratios); 
    585593                   
    586           cout<<"New ratios: "<<ratios[0]<<" "<<ratios[1]<<" "<<ratios[2]<<endl; 
     594          cout<<"New ratios: "<<ratios[0]<<" "<<ratios[1]<<" "<<ratios[2]<<" "<<ratios[3]<<endl; 
    587595 
    588596          //float ratios[] = {1.0f,0.0f,0.0f}; 
    589597           
    590           int nrays[3]; 
    591           float contributions[3]; 
    592           float times[3]; 
     598          int nrays[4]; 
     599          float contributions[4]; 
     600          float times[4]; 
    593601           
    594602          long t1; 
     
    660668          } 
    661669           
     670          if (ratios[3]!=0.0f) { 
     671                t1 = GetTime(); 
     672                GenerateRays(int(mRssSamplesPerPass*ratios[3]), 
     673                                         SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION, rays); 
     674                CastRays(rays, tmpVssRays, true); 
     675                castRays += (int)rays.size(); 
     676#if ADD_RAYS_IN_PLACE  
     677                contributions[3] = mViewCellsManager->ComputeSampleContributions(tmpVssRays, true, false); 
     678#else 
     679                contributions[3] = mViewCellsManager->ComputeSampleContributions(tmpVssRays, false, true); 
     680#endif 
     681                times[3] = TimeDiff(t1, GetTime()); 
     682                nrays[3] = (int)rays.size(); 
     683                 
     684                mStats<<"#DirectionalRelContrib"<<endl<<contributions[3]/nrays[3]<<endl; 
     685                 
     686                vssRays.insert(vssRays.end(), tmpVssRays.begin(), tmpVssRays.end() ); 
     687                 
     688                rays.clear(); 
     689                tmpVssRays.clear(); 
     690          } 
     691 
    662692           
    663693          // now evaluate the ratios for the next pass 
     
    668698          ratios[1] = sqr(contributions[1]/(TIME_WEIGHT*times[1] + (1 - TIME_WEIGHT)*nrays[1])); 
    669699          ratios[2] = sqr(contributions[2]/(TIME_WEIGHT*times[2] + (1 - TIME_WEIGHT)*nrays[2])); 
     700          ratios[3] = sqr(contributions[3]/(TIME_WEIGHT*times[3] + (1 - TIME_WEIGHT)*nrays[3])); 
    670701#else 
    671702          ratios[0] = contributions[0]/(TIME_WEIGHT*times[0] + (1 - TIME_WEIGHT)*nrays[0]); 
    672703          ratios[1] = contributions[1]/(TIME_WEIGHT*times[1] + (1 - TIME_WEIGHT)*nrays[1]); 
    673704          ratios[2] = contributions[2]/(TIME_WEIGHT*times[2] + (1 - TIME_WEIGHT)*nrays[2]); 
     705          ratios[3] = contributions[3]/(TIME_WEIGHT*times[3] + (1 - TIME_WEIGHT)*nrays[3]); 
     706           
    674707#endif     
    675708 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.h

    r1563 r1737  
    1414class RssTreeLeaf; 
    1515 
    16  
     16  class SamplingDistribution { 
     17  public: 
     18        SamplingDistribution() {} 
     19        SamplingDistribution(const int t):mType(t) {} 
     20        int mType; 
     21        int mRays; 
     22        float mContribution; 
     23        float mTime; 
     24  }; 
     25   
    1726/** Sampling based visibility preprocessing. The implementation is  
    1827        based on heuristical sampling of view space  
     
    2130   
    2231public: 
     32  vector<SamplingDistribution> mDistributions; 
    2333  int mSamplesPerPass; 
    2434  int mRssSamplesPerPass; 
     
    4050  //AxisAlignedBox3 *mViewSpaceBox; 
    4151 
     52   
    4253  ofstream mStats; 
    4354  RssTree *mRssTree; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1736 r1737  
    261261 
    262262 
     263void 
     264ViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
     265{ 
     266  GetPreprocessor()->mKdTree->CollectObjects(box, objects); 
     267} 
    263268 
    264269AxisAlignedBox3 ViewCellsManager::GetViewCellBox(ViewCell *vc) 
     
    17311736void ViewCellsManager::UpdatePvs() 
    17321737{ 
    1733         if (mViewCellPvsIsUpdated || !ViewCellsTreeConstructed()) 
    1734                 return; 
    1735  
    1736         mViewCellPvsIsUpdated = true; 
    1737  
    1738         ViewCellContainer leaves; 
    1739         mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
    1740  
    1741         ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    1742  
    1743         for (it = leaves.begin(); it != it_end; ++ it) 
    1744         { 
    1745                 mViewCellsTree->PropagatePvs(*it); 
     1738  if (mViewCellPvsIsUpdated || !ViewCellsTreeConstructed()) 
     1739        return; 
     1740   
     1741  mViewCellPvsIsUpdated = true; 
     1742   
     1743  ViewCellContainer leaves; 
     1744  mViewCellsTree->CollectLeaves(mViewCellsTree->GetRoot(), leaves); 
     1745   
     1746  ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     1747   
     1748  for (it = leaves.begin(); it != it_end; ++ it) 
     1749        { 
     1750          mViewCellsTree->PropagatePvs(*it); 
    17461751        } 
    17471752} 
     
    17501755void ViewCellsManager::GetPvsStatistics(PvsStatistics &stat) 
    17511756{ 
    1752         // update pvs of view cells tree if necessary 
    1753         UpdatePvs(); 
    1754  
    1755         ViewCellContainer::const_iterator it = mViewCells.begin(); 
    1756  
    1757         stat.viewcells = 0; 
    1758         stat.minPvs = 100000000; 
    1759         stat.maxPvs = 0; 
    1760         stat.avgPvs = 0.0f; 
    1761  
    1762         for (; it != mViewCells.end(); ++ it)  
    1763         { 
    1764                 ViewCell *viewcell = *it; 
    1765  
    1766                 const float pvsCost = mViewCellsTree->GetPvsCost(viewcell); 
    1767  
    1768                 if (pvsCost < stat.minPvs) 
    1769                         stat.minPvs = pvsCost; 
    1770                 if (pvsCost > stat.maxPvs) 
    1771                         stat.maxPvs = pvsCost; 
    1772  
    1773                 stat.avgPvs += pvsCost; 
    1774  
    1775                 ++ stat.viewcells; 
    1776         } 
    1777  
    1778         if (stat.viewcells) 
    1779                 stat.avgPvs/=stat.viewcells; 
     1757  // update pvs of view cells tree if necessary 
     1758  UpdatePvs(); 
     1759   
     1760  ViewCellContainer::const_iterator it = mViewCells.begin(); 
     1761   
     1762  stat.viewcells = 0; 
     1763  stat.minPvs = 100000000; 
     1764  stat.maxPvs = 0; 
     1765  stat.avgPvs = 0.0f; 
     1766  stat.avgFilteredPvs = 0.0f; 
     1767  stat.avgFilterContribution = 0.0f; 
     1768   
     1769  for (; it != mViewCells.end(); ++ it)  
     1770        { 
     1771          ViewCell *viewcell = *it; 
     1772           
     1773          const float pvsCost = mViewCellsTree->GetPvsCost(viewcell); 
     1774           
     1775          if (pvsCost < stat.minPvs) 
     1776                stat.minPvs = pvsCost; 
     1777          if (pvsCost > stat.maxPvs) 
     1778                stat.maxPvs = pvsCost; 
     1779           
     1780          stat.avgPvs += pvsCost; 
     1781 
     1782          if (0) { 
     1783                ObjectPvs filteredPvs = viewcell->GetPvs(); 
     1784                ApplyFilter2(viewcell, false, 1.0f, filteredPvs); 
     1785                float filteredCost = filteredPvs.EvalPvsCost(); 
     1786                stat.avgFilteredPvs += filteredCost; 
     1787                stat.avgFilterContribution += filteredCost - pvsCost; 
     1788          } 
     1789           
     1790          ++ stat.viewcells; 
     1791        } 
     1792   
     1793  if (stat.viewcells) { 
     1794        stat.avgPvs/=stat.viewcells; 
     1795        stat.avgFilteredPvs/=stat.viewcells; 
     1796        stat.avgFilterContribution/=stat.viewcells; 
     1797  } 
    17801798} 
    17811799 
     
    17871805  GetPvsStatistics(pvsStat); 
    17881806  s<<"#AVG_PVS\n"<<pvsStat.avgPvs<<endl; 
     1807  s<<"#AVG_FILTERED_PVS\n"<<pvsStat.avgFilteredPvs<<endl; 
     1808  s<<"#AVG_FILTER_CONTRIBUTION\n"<<pvsStat.avgFilterContribution<<endl; 
    17891809  s<<"#MAX_PVS\n"<<pvsStat.maxPvs<<endl; 
    17901810  s<<"#MIN_PVS\n"<<pvsStat.minPvs<<endl; 
     
    24972517void 
    24982518ViewCellsManager::ApplyFilter2(ViewCell *viewCell, 
    2499                                                            KdTree *kdTree, 
     2519                                                           const bool useViewSpaceFilter, 
    25002520                                                           const float filterSize, 
    25012521                                                           ObjectPvs &pvs 
    25022522                                                           ) 
    25032523{ 
    2504   Vector3 center = viewCell->GetBox().Center(); 
     2524  AxisAlignedBox3 vbox = GetViewCellBox(viewCell); 
     2525  Vector3 center = vbox.Center(); 
    25052526  // first determine the average size of the filter 
    2506  
    2507  
    25082527 
    25092528  Intersectable::NewMail(); 
     
    25182537  int pvsSize = 0; 
    25192538  int nPvsSize = 0; 
    2520   int samples = pvs.mSamples; 
    2521  
    2522    
     2539  float samples = pvs.mSamples; 
     2540  cout<<"Samples = "<<samples<<endl; 
     2541  //  cout<<"Filter size = "<<filterSize<<endl; 
     2542  //  cout<<"vbox = "<<vbox<<endl; 
     2543  //  cout<<"center = "<<center<<endl; 
     2544 
     2545 
     2546#define MIN_LOCAL_SAMPLES 5 
     2547 
     2548  // compute the average filter radius 
     2549  float globalC = 2.0f*filterSize/sqrt(samples); 
     2550 
     2551  float sumRadius = 0.0f; 
    25232552  for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi, pvsSize++) { 
    25242553        Intersectable *object = (*oi).first; 
    25252554        // compute filter size based on the distance and the numebr of samples 
    2526         float distance = Distance(center, object->GetBox().Center()); 
    2527  
     2555        AxisAlignedBox3 box = object->GetBox(); 
     2556 
     2557        float distance = Distance(center, box.Center()); 
     2558        float globalRadius = distance*globalC; 
     2559 
     2560        int objectSamples = (int)(*oi).second.mSumPdf; 
     2561        float localRadius = MAX_FLOAT; 
     2562         
     2563        if (objectSamples > MIN_LOCAL_SAMPLES) 
     2564          localRadius = 0.5f*Magnitude(box.Diagonal())/sqrt((float)objectSamples); 
     2565         
    25282566        // now compute the filter size 
    2529         float radius = distance*(filterSize/(4*samples)); 
     2567        float radius = Min(localRadius, globalRadius); 
     2568         
     2569        sumRadius +=radius; 
     2570  } 
     2571   
     2572  float avgRadius = sumRadius/pvsSize; 
     2573  float viewCellRadius = 0.5f*Magnitude(vbox.Diagonal()); 
     2574  cout<<"radius ratio = "<<avgRadius/viewCellRadius<<endl; 
     2575   
     2576  // now compute the filter box around the current viewCell 
     2577 
     2578  if (useViewSpaceFilter) { 
     2579        //      float radius = Max(viewCellRadius/100.0f, avgRadius - viewCellRadius); 
     2580        float radius = viewCellRadius/100.0f; 
     2581        vbox.Enlarge(radius); 
     2582        cout<<"vbox = "<<vbox<<endl; 
     2583        ViewCellContainer viewCells; 
     2584        ComputeBoxIntersections(vbox, viewCells); 
     2585         
     2586        //  cout<<"box="<<box<<endl; 
     2587        ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 
     2588         
     2589        int i; 
     2590        for (i=0; it != it_end; ++ it, ++ i) 
     2591          if ((*it) != viewCell) { 
     2592                //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
     2593                pvs.Merge((*it)->GetPvs()); 
     2594          } 
     2595 
     2596        // update samples and globalC 
     2597        samples = pvs.mSamples; 
     2598        globalC = 2.0f*filterSize/sqrt(samples); 
     2599        cout<<"neighboring viewcells = "<<i-1<<endl; 
     2600        cout<<"Samples' = "<<samples<<endl; 
     2601  } 
     2602   
     2603  for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 
     2604        Intersectable *object = (*oi).first; 
     2605        // compute filter size based on the distance and the numebr of samples 
    25302606        AxisAlignedBox3 box = object->GetBox(); 
     2607 
     2608        float distance = Distance(center, box.Center()); 
     2609        float globalRadius = distance*globalC; 
     2610 
     2611         
     2612        int objectSamples = (int)(*oi).second.mSumPdf; 
     2613        float localRadius = MAX_FLOAT; 
     2614        if (objectSamples > MIN_LOCAL_SAMPLES) 
     2615          localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/sqrt((float)objectSamples); 
     2616         
     2617        //      cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 
     2618         
     2619        // now compute the filter size 
     2620        float radius = Min(localRadius, globalRadius); 
     2621 
     2622        // cout<<"box = "<<box<<endl; 
     2623        //      cout<<"distance = "<<distance<<endl; 
     2624        //      cout<<"radiues = "<<radius<<endl; 
     2625         
    25312626        box.Enlarge(Vector3(radius)); 
    25322627 
    25332628        ObjectContainer objects; 
    25342629        // $$ warning collect objects takes only unmailed ones! 
    2535         // should use VspOsp!! 
    2536         kdTree->CollectObjects(box, objects); 
     2630        CollectObjects(box, objects); 
    25372631        //      cout<<"collected objects="<<objects.size()<<endl; 
    25382632        ObjectContainer::const_iterator noi = objects.begin(); 
     
    25442638        } 
    25452639  } 
    2546   //  cout<<"nPvs size = "<<nPvsSize<<endl; 
     2640  cout<<"nPvs size = "<<nPvsSize<<endl; 
    25472641  pvs.Merge(nPvs); 
     2642  Intersectable::NewMail(); 
    25482643} 
    25492644   
     
    57245819} 
    57255820 
     5821void 
     5822VspOspViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
     5823{ 
     5824  mHierarchyManager->CollectObjects(box, objects); 
     5825} 
     5826 
    57265827 
    57275828#if 1 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1715 r1737  
    6464        struct PvsStatistics  
    6565        { 
    66                 float minPvs; 
    67                 float maxPvs; 
    68                 float avgPvs; 
    69                 int viewcells; 
     66          float minPvs; 
     67          float maxPvs; 
     68          float avgPvs; 
     69          float avgFilteredPvs; 
     70          float avgFilterContribution; 
     71          int viewcells; 
    7072        }; 
    7173 
     
    136138        virtual void Visualize(const ObjectContainer &objects, 
    137139                                                   const VssRayContainer &sampleRays) = 0; 
     140 
     141  /** collect objects intersecting a given spatial box */ 
     142  virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 
    138143 
    139144        /** type of the view cell container. 
     
    464469  void 
    465470  ApplyFilter2(ViewCell *viewCell, 
    466                            KdTree *kdTree, 
     471                           const bool useViewSpaceFilter, 
    467472                           const float filterSize, 
    468473                           ObjectPvs &pvs 
     
    11471152        ///////////////////////////////////////// 
    11481153 
     1154    /** collect objects intersecting a given spatial box */ 
     1155  virtual void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 
     1156 
    11491157        HierarchyManager *mHierarchyManager; 
    11501158}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1733 r1737  
    27692769        ViewCell::NewMail(); 
    27702770 
     2771        nodeStack.push(mRoot); 
     2772         
    27712773        while (!nodeStack.empty())  
    27722774        { 
     
    27762778                const AxisAlignedBox3 bbox = GetBoundingBox(node); 
    27772779 
    2778                 if (bbox.Includes(box)) 
    2779                 { 
    2780                         // node geometry is contained in box 
    2781                         CollectViewCells(node, true, viewCells, true); 
    2782                 } 
    2783                 else if (Overlap(bbox, box)) 
    2784                 { 
    2785                         if (node->IsLeaf()) 
    2786                         { 
    2787                                 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
    2788                          
    2789                                 if (!leaf->GetViewCell()->Mailed() && leaf->TreeValid()) 
     2780                if (Overlap(bbox, box)) { 
     2781                  if (node->IsLeaf()) 
     2782                        { 
     2783                          VspLeaf *leaf = dynamic_cast<VspLeaf *>(node); 
     2784                           
     2785                          if (!leaf->GetViewCell()->Mailed() && leaf->TreeValid()) 
    27902786                                { 
    2791                                         leaf->GetViewCell()->Mail(); 
    2792                                         viewCells.push_back(leaf->GetViewCell()); 
     2787                                  leaf->GetViewCell()->Mail(); 
     2788                                  viewCells.push_back(leaf->GetViewCell()); 
    27932789                                } 
    27942790                        } 
    2795                         else  
    2796                         { 
    2797                                 VspInterior *interior = dynamic_cast<VspInterior *>(node); 
    2798                          
    2799                                 VspNode *first = interior->GetFront(); 
    2800                                 VspNode *second = interior->GetBack(); 
    2801              
    2802                                 nodeStack.push(first); 
    2803                                 nodeStack.push(second); 
    2804                         } 
    2805                 }        
     2791                  else  
     2792                        { 
     2793                          VspInterior *interior = dynamic_cast<VspInterior *>(node); 
     2794                           
     2795                          VspNode *first = interior->GetFront(); 
     2796                          VspNode *second = interior->GetBack(); 
     2797                           
     2798                          nodeStack.push(first); 
     2799                          nodeStack.push(second); 
     2800                        } 
     2801                } 
    28062802                // default: cull 
    28072803        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r1715 r1737  
    1919#filename ../data/vienna/vienna.obj 
    2020 
    21 filename ../data/vienna/vienna-buildings_vienna-roofs_vienna-roads_vienna-plane_cropped.obj 
     21filename ../data/vienna/vienna_cropped.obj 
    2222 
    2323# filename ../data/vienna/viewcells-25-sel.x3d 
     
    5151#       type render 
    5252        detectEmptyViewSpace true 
    53         pvsRenderErrorSamples 0 
    54 #       pvsRenderErrorSamples 5000 
     53#       pvsRenderErrorSamples 0 
     54        pvsRenderErrorSamples 1000 
    5555        quitOnFinish true 
    5656        computeVisibility true 
     
    8484        vssSamples 50000000 
    8585#       vssSamples 1000000 
    86         vssSamplesPerPass 2000000 
     86        vssSamplesPerPass 3000000 
    8787        useImportanceSampling true 
    8888 
     
    196196        #type vspKdTree 
    197197        #type bspTree 
    198         type vspBspTree 
    199         #type vspOspTree 
     198        #type vspBspTree 
     199        type vspOspTree 
    200200        #type sceneDependent 
    201201         
     
    289289#       filename ../data/vienna/vsposp-seq-viewCells.xml.gz 
    290290 
    291         filename ../data/vienna/vienna_cropped-2-sequential-30000-viewcells.xml.gz 
     291        filename ../data/vienna/vienna_cropped-gradient-2-viewcells.xml.gz 
     292 
     293#       filename ../data/vienna/vienna_cropped-2-sequential-30000-viewcells.xml.gz 
    292294#       filename ../data/vienna/vienna_cropped-sequential-400000-viewcells.xml.gz 
    293295 
Note: See TracChangeset for help on using the changeset viewer.