Changeset 563


Ignore:
Timestamp:
01/21/06 18:32:30 (18 years ago)
Author:
bittner
Message:

rss sampling changes, preprocessor::GenerateRays?

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

Legend:

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

    r547 r563  
    14341434                                        "false"); 
    14351435 
     1436        RegisterOption("Preprocessor.pvsRenderErrorSamples", 
     1437                                   optInt, 
     1438                                   "pvsRenderErrorSamples=", 
     1439                                   "10000"); 
     1440 
    14361441        RegisterOption("Preprocessor.useGlDebugger", 
    14371442                                        optBool, 
     
    16751680        RegisterOption("RssPreprocessor.Export.numRays", optInt, "rss_export_num_rays=", "5000"); 
    16761681        RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells", "false"); 
    1677         RegisterOption("RssPreprocessor.updateSubdivision", optBool, "rss_update_subdivision", "false"); 
     1682        RegisterOption("RssPreprocessor.updateSubdivision", 
     1683                                   optBool, 
     1684                                   "rss_update_subdivision", 
     1685                                   "false"); 
    16781686 
    16791687 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp

    r561 r563  
    77#include "Beam.h" 
    88#include "KdTree.h" 
     9#include "Environment.h" 
    910 
    1011#include <GL/glext.h> 
     
    191192 
    192193void 
    193 GlRenderer::RandomViewPoint() 
     194GlRendererBuffer::RandomViewPoint() 
    194195{ 
    195196  Vector3 pVector = Vector3(halton.GetNumber(1), 
     
    201202                                                        0.0f); 
    202203   
    203   mViewPoint = mSceneGraph->GetBox().GetPoint(pVector); 
     204  //  viewcells->GetViewPoint(mViewPoint); 
     205 
     206  mViewPoint =  mSceneGraph->GetBox().GetPoint(pVector); 
    204207   
    205208  mViewDirection = Normalize(Vector3(sin(dVector.x), 
     
    211214} 
    212215 
     216 
     217GlRendererBuffer::GlRendererBuffer(const int w, 
     218                                                                   const int h, 
     219                                                                   SceneGraph *sceneGraph, 
     220                                                                   ViewCellsManager *viewcells, 
     221                                                                   KdTree *tree): 
     222QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells, tree) { 
     223  
     224 environment->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames); 
     225   mPvsErrorBuffer.resize(mPvsStatFrames); 
     226         ClearErrorBuffer(); 
     227            
     228           InitGL(); 
     229                  
     230                 } 
    213231 
    214232float 
     
    947965 makeCurrent();  
    948966 GlRenderer::InitGL(); 
    949 #if 0 
     967#if 1 
    950968        // initialise dual depth buffer textures 
    951969        glGenTextures(1, &frontDepthMap); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h

    r556 r563  
    9090  void SetupMaterial(Material *m); 
    9191  virtual void SetupCamera(); 
    92   void RandomViewPoint(); 
    9392   
    9493  bool 
     
    119118                                         SceneGraph *sceneGraph, 
    120119                                         ViewCellsManager *viewcells, 
    121                                          KdTree *tree): 
    122         QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells, tree) { 
    123  
    124         mPvsStatFrames = 5000; 
    125         mPvsErrorBuffer.resize(mPvsStatFrames); 
    126         ClearErrorBuffer(); 
    127  
    128 //      makeCurrent(); 
    129 //      InitGL(); 
    130 //      doneCurrent(); 
    131  
    132         } 
     120                                         KdTree *tree); 
     121 
    133122   
    134123  void 
     
    143132 
    144133 
     134  void RandomViewPoint(); 
    145135  void SampleBeamContributions( 
    146136                                                           Intersectable *sourceObject, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Makefile

    r556 r563  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.0) on: ?t 19. I 11:57:31 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.0) on: ?t 19. I 16:46:41 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
     
    77############################################################################# 
    88 
    9 first: debug 
    10 install: debug-install 
    11 uninstall: debug-uninstall 
     9first: release 
     10install: release-install 
     11uninstall: release-uninstall 
    1212MAKEFILE      = Makefile 
    1313QMAKE         = qmake 
     
    2727MKDIR         = mkdir 
    2828SUBTARGETS    =  \ 
    29                 debug \ 
    30                 release 
     29                release \ 
     30                debug 
    3131 
     32release: $(MAKEFILE).Release FORCE 
     33        $(MAKE) -f $(MAKEFILE).Release 
     34release-make_default: $(MAKEFILE).Release FORCE 
     35        $(MAKE) -f $(MAKEFILE).Release  
     36release-make_first: $(MAKEFILE).Release FORCE 
     37        $(MAKE) -f $(MAKEFILE).Release first 
     38release-all: $(MAKEFILE).Release FORCE 
     39        $(MAKE) -f $(MAKEFILE).Release all 
     40release-clean: $(MAKEFILE).Release FORCE 
     41        $(MAKE) -f $(MAKEFILE).Release clean 
     42release-distclean: $(MAKEFILE).Release FORCE 
     43        $(MAKE) -f $(MAKEFILE).Release distclean 
     44release-install: $(MAKEFILE).Release FORCE 
     45        $(MAKE) -f $(MAKEFILE).Release install 
     46release-uninstall: $(MAKEFILE).Release FORCE 
     47        $(MAKE) -f $(MAKEFILE).Release uninstall 
    3248debug: $(MAKEFILE).Debug FORCE 
    3349        $(MAKE) -f $(MAKEFILE).Debug 
     
    4662debug-uninstall: $(MAKEFILE).Debug FORCE 
    4763        $(MAKE) -f $(MAKEFILE).Debug uninstall 
    48 release: $(MAKEFILE).Release FORCE 
    49         $(MAKE) -f $(MAKEFILE).Release 
    50 release-make_default: $(MAKEFILE).Release FORCE 
    51         $(MAKE) -f $(MAKEFILE).Release  
    52 release-make_first: $(MAKEFILE).Release FORCE 
    53         $(MAKE) -f $(MAKEFILE).Release first 
    54 release-all: $(MAKEFILE).Release FORCE 
    55         $(MAKE) -f $(MAKEFILE).Release all 
    56 release-clean: $(MAKEFILE).Release FORCE 
    57         $(MAKE) -f $(MAKEFILE).Release clean 
    58 release-distclean: $(MAKEFILE).Release FORCE 
    59         $(MAKE) -f $(MAKEFILE).Release distclean 
    60 release-install: $(MAKEFILE).Release FORCE 
    61         $(MAKE) -f $(MAKEFILE).Release install 
    62 release-uninstall: $(MAKEFILE).Release FORCE 
    63         $(MAKE) -f $(MAKEFILE).Release uninstall 
    6464 
    6565Makefile: preprocessor.pro  D:/Qt/4.1.0/mkspecs/win32-msvc.net\qmake.conf D:/Qt/4.1.0/mkspecs/qconfig.pri \ 
     
    6868                D:\Qt\4.1.0\mkspecs\features\default_pre.prf \ 
    6969                D:\Qt\4.1.0\mkspecs\features\win32\default_pre.prf \ 
    70                 D:\Qt\4.1.0\mkspecs\features\debug.prf \ 
     70                D:\Qt\4.1.0\mkspecs\features\release.prf \ 
    7171                D:\Qt\4.1.0\mkspecs\features\debug_and_release.prf \ 
    7272                D:\Qt\4.1.0\mkspecs\features\default_post.prf \ 
     
    8989D:\Qt\4.1.0\mkspecs\features\default_pre.prf: 
    9090D:\Qt\4.1.0\mkspecs\features\win32\default_pre.prf: 
    91 D:\Qt\4.1.0\mkspecs\features\debug.prf: 
     91D:\Qt\4.1.0\mkspecs\features\release.prf: 
    9292D:\Qt\4.1.0\mkspecs\features\debug_and_release.prf: 
    9393D:\Qt\4.1.0\mkspecs\features\default_post.prf: 
     
    109109qmake_all: FORCE 
    110110 
    111 make_default: debug-make_default release-make_default FORCE 
    112 make_first: debug-make_first release-make_first FORCE 
    113 all: debug-all release-all FORCE 
    114 clean: debug-clean release-clean FORCE 
     111make_default: release-make_default debug-make_default FORCE 
     112make_first: release-make_first debug-make_first FORCE 
     113all: release-all debug-all FORCE 
     114clean: release-clean debug-clean FORCE 
    115115        -$(DEL_FILE) preprocessor.exp 
    116         -$(DEL_FILE) preprocessor.pdb 
    117         -$(DEL_FILE) preprocessor.ilk 
    118         -$(DEL_FILE) vc*.pdb 
    119         -$(DEL_FILE) vc*.idb 
    120 distclean: debug-distclean release-distclean FORCE 
     116distclean: release-distclean debug-distclean FORCE 
    121117        -$(DEL_FILE) Makefile 
    122118 
     119release-mocclean: $(MAKEFILE).Release 
     120        $(MAKE) -f $(MAKEFILE).Release mocclean 
    123121debug-mocclean: $(MAKEFILE).Debug 
    124122        $(MAKE) -f $(MAKEFILE).Debug mocclean 
    125 release-mocclean: $(MAKEFILE).Release 
    126         $(MAKE) -f $(MAKEFILE).Release mocclean 
    127 mocclean: debug-mocclean release-mocclean 
     123mocclean: release-mocclean debug-mocclean 
    128124 
     125release-mocables: $(MAKEFILE).Release 
     126        $(MAKE) -f $(MAKEFILE).Release mocables 
    129127debug-mocables: $(MAKEFILE).Debug 
    130128        $(MAKE) -f $(MAKEFILE).Debug mocables 
    131 release-mocables: $(MAKEFILE).Release 
    132         $(MAKE) -f $(MAKEFILE).Release mocables 
    133 mocables: debug-mocables release-mocables 
     129mocables: release-mocables debug-mocables 
    134130FORCE: 
    135131 
     132$(MAKEFILE).Release: Makefile 
    136133$(MAKEFILE).Debug: Makefile 
    137 $(MAKEFILE).Release: Makefile 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r556 r563  
    3333Preprocessor::~Preprocessor() 
    3434{ 
    35   cerr<<"Deleting view cells manager...\n"; 
     35  Debug<<"Deleting view cells manager...\n"; 
    3636  DEL_PTR(mViewCellsManager); 
    37   cerr<<"done.\n"; 
    38   cerr<<"Deleting bsp tree...\n"; 
     37  Debug<<"done.\n"; 
     38  Debug<<"Deleting bsp tree...\n"; 
    3939  DEL_PTR(mBspTree); 
    40   cerr<<"done.\n"; 
    41   cerr<<"Deleting kd tree...\n"; 
     40  Debug<<"done.\n"; 
     41  Debug<<"Deleting kd tree...\n"; 
    4242  DEL_PTR(mKdTree); 
    43   cerr<<"done.\n"; 
    44   cerr<<"Deleting vspkd tree...\n"; 
     43  Debug<<"done.\n"; 
     44  Debug<<"Deleting vspkd tree...\n"; 
    4545  DEL_PTR(mVspKdTree); 
    46   cerr<<"done.\n"; 
    47   cerr<<"Deleting vspbsp tree...\n"; 
     46  Debug<<"done.\n"; 
     47  Debug<<"Deleting vspbsp tree...\n"; 
    4848  DEL_PTR(mVspBspTree); 
    49   cerr<<"done.\n"; 
     49  Debug<<"done.\n"; 
    5050} 
    5151 
     
    429429        return true; 
    430430} 
     431 
     432 
     433 
     434bool 
     435Preprocessor::GenerateRays( 
     436                                                   const int number, 
     437                                                   const int sampleType, 
     438                                                   SimpleRayContainer &rays 
     439                                                   ) 
     440{ 
     441  Vector3 origin, direction;  
     442 
     443  for (int i=0; rays.size() < number; i++) { 
     444        mViewCellsManager->GetViewPoint(origin); 
     445         
     446         
     447        // now get the direction 
     448        switch (sampleType) { 
     449        case OBJECT_BASED_DISTRIBUTION: { 
     450          Vector3 point; 
     451          Vector3 normal; 
     452          int i = RandomValue(0, mObjects.size() - 1); 
     453          Intersectable *object = mObjects[i]; 
     454          object->GetRandomSurfacePoint(point, normal); 
     455          direction = point - origin; 
     456        } 
     457          break; 
     458        case DIRECTION_BASED_DISTRIBUTION: 
     459          direction = UniformRandomVector(); 
     460          break; 
     461        case DIRECTION_BOX_BASED_DISTRIBUTION: { 
     462          float alpha = RandomValue(0.0f, 2*M_PI); 
     463          float beta = RandomValue(-M_PI/2, M_PI/2); 
     464          direction = VssRay::GetDirection(alpha, beta); 
     465          break; 
     466        } 
     467        case SPATIAL_BOX_BASED_DISTRIBUTION: 
     468          direction = mKdTree->GetBox().GetRandomPoint() - origin; 
     469          break; 
     470        default: 
     471          // unsuported distribution type 
     472          return false; 
     473        } 
     474        // $$ jb the pdf is yet not correct for all sampling methods! 
     475        float pdf = 1.0f; 
     476        float c = Magnitude(direction); 
     477        if (c > Limits::Small) { 
     478          direction*=1.0f/c; 
     479          rays.AddRay(SimpleRay(origin, direction, pdf)); 
     480        } 
     481  } 
     482  return true; 
     483} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r538 r563  
    9898  bool ExportSamples(const VssRayContainer &samples) const; 
    9999 
     100  /** Get Sample rays of particular type, returns false if this 
     101          type of rays is not supported by the preprocessor 
     102  */ 
     103  enum { 
     104        OBJECT_BASED_DISTRIBUTION, 
     105        DIRECTION_BASED_DISTRIBUTION, 
     106        DIRECTION_BOX_BASED_DISTRIBUTION, 
     107        SPATIAL_BOX_BASED_DISTRIBUTION, 
     108        RSS_BASED_DISTRIBUTION, 
     109        RSS_SILHOUETTE_BASED_DISTRIBUTION, 
     110        VSS_BASED_DISTRIBUTION 
     111  }; 
     112   
     113  virtual bool 
     114  GenerateRays( 
     115                           const int number, 
     116                           const int raysType, 
     117                           SimpleRayContainer &rays 
     118                           ); 
     119   
    100120  /// scene graph loaded from file 
    101121  SceneGraph *mSceneGraph; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h

    r556 r563  
    325325          (*it).mPdf*=c; 
    326326  } 
    327    
     327 
     328  void AddRay(const SimpleRay &ray) { 
     329        push_back(ray); 
     330        mSumPdf += ray.mPdf; 
     331  } 
    328332}; 
    329333 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r556 r563  
    4242  environment->GetBoolValue("RssPreprocessor.loadInitialSamples", mLoadInitialSamples); 
    4343  environment->GetBoolValue("RssPreprocessor.storeInitialSamples", mStoreInitialSamples); 
     44  environment->GetBoolValue("RssPreprocessor.updateSubdivision", mUpdateSubdivision); 
    4445   
    4546  mStats.open("stats.log"); 
    46  
    47 } 
     47  mRssTree = NULL; 
     48} 
     49 
     50 
     51bool 
     52RssPreprocessor::GenerateRays( 
     53                                                          const int number, 
     54                                                          const int sampleType, 
     55                                                          SimpleRayContainer &rays 
     56                                                          ) 
     57{ 
     58  bool result = false; 
     59 
     60  switch (sampleType) { 
     61  case RSS_BASED_DISTRIBUTION: 
     62  case RSS_SILHOUETTE_BASED_DISTRIBUTION: 
     63        if (mRssTree) { 
     64          GenerateImportanceRays(mRssTree, number, rays); 
     65          result = true; 
     66          rays.NormalizePdf(); 
     67        } 
     68        break; 
     69  default: 
     70        result = Preprocessor::GenerateRays(number, sampleType, rays); 
     71  } 
     72 
     73  return result; 
     74} 
     75 
     76void 
     77RssPreprocessor::CastRays( 
     78                                                  SimpleRayContainer &rays, 
     79                                                  VssRayContainer &vssRays 
     80                                                  ) 
     81{ 
     82  for (int i=0; i < rays.size(); i++) 
     83        CastRay(rays[i].mOrigin, rays[i].mDirection, rays[i].mPdf, vssRays); 
     84} 
     85 
    4886 
    4987RssPreprocessor::~RssPreprocessor() 
     
    190228} 
    191229 
    192 Vector3 
    193 RssPreprocessor::GetDirection(const Vector3 &viewpoint, 
    194                                                           AxisAlignedBox3 *viewSpaceBox 
    195                                                           ) 
    196 { 
    197   Vector3 point; 
    198   if (!use2dSampling) { 
    199         if (mObjectBasedSampling) { 
    200           Vector3 normal; 
    201           int i = RandomValue(0, mObjects.size()-1); 
    202           Intersectable *object = mObjects[i]; 
    203           object->GetRandomSurfacePoint(point, normal); 
    204         } else { 
    205           // select 
    206           if (mDirectionalSampling) { 
    207                 point = viewpoint + UniformRandomVector(); 
    208           } else { 
    209                 // select the other point uniformly distruted in the whole viewspace 
    210                 AxisAlignedBox3 box; 
    211                  
    212                 if (viewSpaceBox) 
    213                   box =*viewSpaceBox; 
    214                 else  
    215                   box = mKdTree->GetBox(); 
    216                  
    217                 point = box.GetRandomPoint(); 
    218           } 
    219         } 
    220   } else { 
    221         AxisAlignedBox3 box; 
    222                  
    223         if (viewSpaceBox) 
    224           box =*viewSpaceBox; 
    225         else  
    226           box = mKdTree->GetBox(); 
    227          
    228         point = box.GetRandomPoint(); 
    229         point.y = viewpoint.y; 
    230   } 
    231          
    232   return point - viewpoint; 
    233 } 
    234  
    235 Vector3 
    236 RssPreprocessor::InitialGetDirection(const Vector3 &viewpoint, 
    237                                                                          AxisAlignedBox3 *viewSpaceBox 
    238                                                                          ) 
    239 { 
    240   Vector3 point; 
    241   if (!use2dSampling) { 
    242         if (1 || mObjectBasedSampling) { 
    243           Vector3 normal; 
    244           int i = RandomValue(0, mObjects.size()-1); 
    245           Intersectable *object = mObjects[i]; 
    246           object->GetRandomSurfacePoint(point, normal); 
    247         } else { 
    248           // select 
    249           if (1 || mDirectionalSampling) { 
    250                 point = viewpoint + UniformRandomVector(); 
    251           } else { 
    252                 // select the other point uniformly distruted in the whole viewspace 
    253                 AxisAlignedBox3 box; 
    254                  
    255                 if (viewSpaceBox) 
    256                   box =*viewSpaceBox; 
    257                 else  
    258                   box = mKdTree->GetBox(); 
    259                  
    260                 point = box.GetRandomPoint(); 
    261           } 
    262         } 
    263   } else { 
    264         AxisAlignedBox3 box; 
    265          
    266         if (viewSpaceBox) 
    267           box =*viewSpaceBox; 
    268         else  
    269           box = mKdTree->GetBox(); 
    270          
    271         point = box.GetRandomPoint(); 
    272         point.y = viewpoint.y; 
    273   } 
    274    
    275   return point - viewpoint; 
    276 } 
    277230 
    278231int 
     
    302255  } 
    303256         
    304   cout<<"Generated "<<num<<" rays."<<endl; 
    305257         
    306258  return num; 
     
    322274  exporter->SetFilled(); 
    323275  // $$JB temporarily do not export the scene 
    324   if (1) 
     276  if (0) 
    325277        exporter->ExportScene(mSceneGraph->mRoot); 
    326278  exporter->SetWireframe(); 
     
    474426} 
    475427 
     428 
     429 
    476430bool 
    477431RssPreprocessor::ComputeVisibility() 
    478432{ 
    479433 
    480   if (renderer) 
    481         renderer->InitGL(); 
    482    
    483434  //  connect(this, SIGNAL(EvalPvsStat()), renderer, SLOT(EvalPvsStat()) ); 
    484435   
     
    493444  int totalSamples = 0; 
    494445 
    495   AxisAlignedBox3 *box = new AxisAlignedBox3(mKdTree->GetBox()); 
    496  
    497   if (fromBoxVisibility) { 
    498         float m = box->Min(1); 
    499         float bsize = box->Size(1); 
    500  
    501         float size = 0.02f; 
    502         float s = 0.5f - size; 
    503         float olds = Magnitude(box->Size()); 
    504         box->Enlarge(box->Size()*Vector3(-s)); 
    505         //      Vector3 translation = Vector3(-olds*0.2f, 0, 0); 
    506         Vector3 translation = Vector3(-0.05f*olds, 0, 0); 
    507         box->SetMin(box->Min() + translation); 
    508         box->SetMax(box->Max() + translation); 
    509  
    510         box->SetMin(1,  m + bsize*0.1f); 
    511         box->SetMax(1,  m + bsize*0.6f); 
    512  
    513          
    514   } else { 
    515                  
    516         // sample city like heights 
    517         float m = box->Min(1); 
    518         float bsize = box->Size(1); 
    519         box->SetMin(1,  m + bsize*0.2f); 
    520         box->SetMax(1,  m + bsize*0.3f); 
    521   } 
    522  
    523   if (use2dSampling) 
    524         box->SetMax(1, box->Min(1)); 
    525          
    526   if (useViewSpaceBox) 
    527   { 
    528         mViewSpaceBox = box; 
    529         mViewCellsManager->SetViewSpaceBox(*box); 
    530   } 
    531   else 
    532   { 
    533         mViewSpaceBox = NULL; 
    534         mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 
    535   } 
     446  mViewSpaceBox = NULL; 
     447  mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 
     448   
    536449   
    537450  //-- load view cells from file if requested 
    538   if (mLoadViewCells) 
    539   {      
    540           // load now because otherwise bounding box not correct 
    541           mViewCellsManager->LoadViewCells(mViewCellsFilename, &mObjects); 
    542   } 
    543  
    544   RssTree *rssTree = NULL; 
     451  if (mLoadViewCells) {  
     452        // load now because otherwise bounding box not correct 
     453        mViewCellsManager->LoadViewCells(mViewCellsFilename, &mObjects); 
     454  } 
     455   
    545456  int rssPass = 0; 
    546457  int rssSamples = 0; 
    547  
    548 #if 0 
     458   
    549459  if (mLoadInitialSamples) { 
    550460        cout << "Loading samples from file ... "; 
     
    552462        cout << "finished\n" << endl; 
    553463  } else { 
    554 #endif 
    555         while (totalSamples < mInitialSamples) { 
    556           int passContributingSamples = 0; 
    557           int passSampleContributions = 0; 
    558           int passSamples = 0; 
    559           int index = 0; 
    560            
    561           int sampleContributions; 
    562            
    563           //int s = Min(mSamplesPerPass, mInitialSamples); 
    564           int s = mInitialSamples; 
    565  
    566           float probability = 1.0f/mInitialSamples; 
    567           for (int k=0; k < s; k++) { 
    568                  
    569                  
    570                 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 
    571                 Vector3 viewpoint;  
    572                 mViewCellsManager->GetViewPoint(viewpoint); 
    573                 //              viewpoint = GetViewpoint(mViewSpaceBox); 
    574                 Vector3 direction = InitialGetDirection(viewpoint, mViewSpaceBox); 
    575                  
    576                 sampleContributions = CastRay(viewpoint, direction, probability, mVssRays); 
    577                  
    578                  
    579                 //-- CORR matt: put block inside loop 
    580                 if (sampleContributions) { 
    581                   passContributingSamples ++; 
    582                   passSampleContributions += sampleContributions; 
    583                 } 
    584                 passSamples++; 
    585                 totalSamples++; 
    586           } 
    587            
    588            
    589           float avgRayContrib = (passContributingSamples > 0) ?  
    590                 passSampleContributions/(float)passContributingSamples : 0; 
    591            
    592           cout << "#Pass " << mPass << " : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    593           cout << "#TotalSamples=" << totalSamples/1000  
    594                    << "k   #SampleContributions=" << passSampleContributions << " ("  
    595                    << 100*passContributingSamples/(float)passSamples<<"%)"  
    596                    << "avgcontrib=" << avgRayContrib << endl; 
    597            
    598           mPass++; 
    599         } 
    600            
    601         cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    602         cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl <<flush; 
    603          
    604         rssSamples += (int)mVssRays.size(); 
    605          
    606          
    607         if (mExportRays) { 
    608           char filename[64]; 
    609           sprintf(filename, "rss-rays-initial.x3d"); 
    610           ExportRays(filename, mVssRays, mExportNumRays); 
    611         } 
    612          
    613         if (mStoreInitialSamples) 
    614           { 
    615                 cout << "Writing samples to file ... "; 
    616                 ExportSamples(mVssRays); 
    617                 cout << "finished\n" << endl; 
    618           } 
    619          
    620         if (mUseViewcells) { 
    621           // construct view cells 
    622           if (!mLoadViewCells) 
    623                 mViewCellsManager->Construct(mObjects, mVssRays); 
    624           // evaluate contributions of the intitial rays 
    625           mViewCellsManager->ComputeSampleContributions(mVssRays); 
    626            
    627            
    628           mStats << 
    629                 "#Pass\n" <<mPass<<endl<< 
    630                 "#RssPass\n" <<rssPass<<endl<< 
    631                 "#Time\n" << TimeDiff(startTime, GetTime())*1e-3<<endl<< 
    632                 "#TotalSamples\n" <<totalSamples<<endl<< 
    633                 "#RssSamples\n" <<rssSamples<<endl; 
    634            
    635  
    636           mVssRays.PrintStatistics(mStats); 
    637           mViewCellsManager->PrintPvsStatistics(mStats); 
    638            
    639           VssRayContainer selectedRays; 
    640           int desired = Max( 
    641                                                 mViewCellsManager->GetPostProcessSamples(), 
    642                                                 mViewCellsManager->GetVisualizationSamples()); 
    643            
    644           mVssRays.SelectRays(desired, selectedRays); 
    645            
    646           //-- post process view cells 
    647           mViewCellsManager->PostProcess(mObjects, selectedRays); 
    648            
    649           //-- several visualizations and statistics 
    650           Debug << "view cells after post processing: " << endl; 
    651           mViewCellsManager->PrintStatistics(Debug); 
    652            
    653           if (1)  
    654                 mViewCellsManager->Visualize(mObjects, selectedRays); 
    655  
    656           ComputeRenderError(); 
    657            
    658         } 
    659  
    660  
    661    
    662   rssPass++; 
    663    
    664   rssTree = new RssTree; 
    665   rssTree->SetPass(mPass); 
    666    
    667   /// compute view cell contribution of rays if view cells manager already constructed 
    668   mViewCellsManager->ComputeSampleContributions(mVssRays); 
    669  
    670   if (mUseImportanceSampling) { 
    671          
    672         //      if (fromBoxVisibility) 
    673         //        rssTree->Construct(mObjects, mVssRays, mViewSpaceBox); 
    674         //      else 
    675         rssTree->Construct(mObjects, mVssRays); 
    676  
    677         rssTree->stat.Print(mStats); 
    678         cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 
    679          
    680         if (mExportRssTree) { 
    681           ExportRssTree("rss-tree-100.x3d", rssTree, Vector3(1,0,0)); 
    682           ExportRssTree("rss-tree-001.x3d", rssTree, Vector3(0,0,1)); 
    683           ExportRssTree("rss-tree-101.x3d", rssTree, Vector3(1,0,1)); 
    684           ExportRssTree("rss-tree-101m.x3d", rssTree, Vector3(-1,0,-1)); 
    685           ExportRssTreeLeaves(rssTree, 10); 
    686         } 
    687          
    688         if (mExportPvs) { 
    689           ExportPvs("rss-pvs-initial.x3d", rssTree); 
    690         } 
    691   } 
    692    
    693   // viewcells->UpdatePVS(newVssRays); 
    694    
    695  
    696   while (1) { 
    697         int num = mRssSamplesPerPass; 
    698464        SimpleRayContainer rays; 
    699         VssRayContainer vssRays; 
    700  
    701  
    702         if (!mUseImportanceSampling) { 
    703           for (int j=0; j < num; j++) { 
    704             //changed by matt 
    705                 //Vector3 viewpoint = GetViewpoint(mViewSpaceBox);  
    706                 Vector3 viewpoint;  
    707                 mViewCellsManager->GetViewPoint(viewpoint); 
    708                 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 
    709                 rays.push_back(SimpleRay(viewpoint, direction, 1.0f)); 
    710                 rays.mSumPdf += 1.0f; 
    711           } 
    712         } else { 
    713           num = GenerateImportanceRays(rssTree, num, rays); 
    714         } 
    715  
    716         rays.NormalizePdf(); 
    717          
    718         for (int i=0; i < rays.size(); i++) 
    719           CastRay(rays[i].mOrigin, rays[i].mDirection, rays[i].mPdf, vssRays); 
    720  
    721          
    722         totalSamples += (int)rays.size(); 
    723         rssSamples += (int)vssRays.size(); 
    724  
     465 
     466        GenerateRays(mInitialSamples, SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
     467         
     468        CastRays(rays, mVssRays); 
     469  } 
     470   
     471  cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl <<flush; 
     472   
     473  rssSamples += (int)mVssRays.size(); 
     474  totalSamples += mInitialSamples; 
     475  mPass++; 
     476   
     477  if (mExportRays) { 
     478        char filename[64]; 
     479        sprintf(filename, "rss-rays-initial.x3d"); 
     480        ExportRays(filename, mVssRays, mExportNumRays); 
     481  } 
     482   
     483  if (mStoreInitialSamples) { 
     484        cout << "Writing samples to file ... "; 
     485        ExportSamples(mVssRays); 
     486        cout << "finished\n" << endl; 
     487  } 
     488         
     489  if (mUseViewcells) { 
     490        // construct view cells 
     491        if (!mLoadViewCells) 
     492          mViewCellsManager->Construct(mObjects, mVssRays); 
     493 
     494         
     495 
     496        // evaluate contributions of the intitial rays 
     497        mViewCellsManager->ComputeSampleContributions(mVssRays); 
    725498         
    726499         
     
    731504          "#TotalSamples\n" <<totalSamples<<endl<< 
    732505          "#RssSamples\n" <<rssSamples<<endl; 
     506         
     507 
     508        mVssRays.PrintStatistics(mStats); 
     509        mViewCellsManager->PrintPvsStatistics(mStats); 
     510           
     511        VssRayContainer selectedRays; 
     512        int desired = Max( 
     513                                          mViewCellsManager->GetPostProcessSamples(), 
     514                                          mViewCellsManager->GetVisualizationSamples()); 
     515         
     516        mVssRays.SelectRays(desired, selectedRays); 
     517           
     518        //-- post process view cells 
     519        mViewCellsManager->PostProcess(mObjects, selectedRays); 
     520           
     521        //-- several visualizations and statistics 
     522        Debug << "view cells after post processing: " << endl; 
     523        mViewCellsManager->PrintStatistics(Debug); 
     524         
     525        if (1)  
     526          mViewCellsManager->Visualize(mObjects, selectedRays); 
     527         
     528        ComputeRenderError(); 
     529  } 
     530   
     531  rssPass++; 
     532   
     533  mRssTree = new RssTree; 
     534  mRssTree->SetPass(mPass); 
     535   
     536  /// compute view cell contribution of rays if view cells manager already constructed 
     537  mViewCellsManager->ComputeSampleContributions(mVssRays); 
     538 
     539  if (mUseImportanceSampling) { 
     540         
     541        mRssTree->Construct(mObjects, mVssRays); 
     542         
     543        mRssTree->stat.Print(mStats); 
     544        cout<<"RssTree root PVS size = "<<mRssTree->GetRootPvsSize()<<endl; 
     545         
     546        if (mExportRssTree) { 
     547          ExportRssTree("rss-tree-100.x3d", mRssTree, Vector3(1,0,0)); 
     548          ExportRssTree("rss-tree-001.x3d", mRssTree, Vector3(0,0,1)); 
     549          ExportRssTree("rss-tree-101.x3d", mRssTree, Vector3(1,0,1)); 
     550          ExportRssTree("rss-tree-101m.x3d", mRssTree, Vector3(-1,0,-1)); 
     551          ExportRssTreeLeaves(mRssTree, 10); 
     552        } 
     553         
     554        if (mExportPvs) { 
     555          ExportPvs("rss-pvs-initial.x3d", mRssTree); 
     556        } 
     557  } 
     558   
     559  // viewcells->UpdatePVS(newVssRays); 
     560   
     561 
     562  while (1) { 
     563        SimpleRayContainer rays; 
     564        VssRayContainer vssRays; 
     565        int castRays = 0; 
     566        if (mUseImportanceSampling) { 
     567          VssRayContainer tmpVssRays; 
     568           
     569          GenerateRays(mRssSamplesPerPass/2, RSS_BASED_DISTRIBUTION, rays); 
     570          CastRays(rays, tmpVssRays); 
     571          castRays += rays.size(); 
     572          float c1 = mViewCellsManager->ComputeSampleContributions(tmpVssRays, false); 
     573          mStats<<"#RssRelContrib"<<endl<<c1/rays.size()<<endl; 
     574 
     575          vssRays.insert(vssRays.end(), tmpVssRays.begin(), tmpVssRays.end() ); 
     576          rays.clear(); 
     577          tmpVssRays.clear(); 
     578           
     579          GenerateRays(mRssSamplesPerPass/4, SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
     580          CastRays(rays, tmpVssRays); 
     581          castRays += rays.size(); 
     582          float c2 = mViewCellsManager->ComputeSampleContributions(tmpVssRays, false); 
     583          mStats<<"#SpatialRelContrib"<<endl<<c2/rays.size()<<endl; 
     584 
     585          vssRays.insert(vssRays.end(), tmpVssRays.begin(), tmpVssRays.end() ); 
     586           
     587          rays.clear(); 
     588          tmpVssRays.clear(); 
     589           
     590           
     591          GenerateRays(mRssSamplesPerPass/4, DIRECTION_BASED_DISTRIBUTION, rays); 
     592          CastRays(rays, tmpVssRays); 
     593          castRays += rays.size(); 
     594          float c3 = mViewCellsManager->ComputeSampleContributions(tmpVssRays, false); 
     595          mStats<<"#DirectionalRelContrib"<<endl<<c3/rays.size()<<endl; 
     596           
     597          vssRays.insert(vssRays.end(), tmpVssRays.begin(), tmpVssRays.end() ); 
     598           
     599          rays.clear(); 
     600          tmpVssRays.clear(); 
     601           
     602          // add contributions of all rays at once... 
     603          mViewCellsManager->AddSampleContributions(vssRays); 
     604           
     605        } 
     606        else { 
     607          int rayType = SPATIAL_BOX_BASED_DISTRIBUTION; 
     608          if (mObjectBasedSampling) 
     609                rayType = OBJECT_BASED_DISTRIBUTION; 
     610          else 
     611                if (mDirectionalSampling) 
     612                  rayType = DIRECTION_BASED_DISTRIBUTION; 
     613           
     614          GenerateRays(mRssSamplesPerPass, rayType, rays); 
     615          CastRays(rays, vssRays); 
     616          castRays += rays.size(); 
     617          if (mUseViewcells) { 
     618                /// compute view cell contribution of rays 
     619                mViewCellsManager->ComputeSampleContributions(vssRays); 
     620          } 
     621                 
     622           
     623        } 
     624        totalSamples += castRays; 
     625        rssSamples += (int)vssRays.size(); 
     626 
     627        cout<<"Generated "<<castRays<<" rays, progress "<<totalSamples/((float) mRssSamples + 
     628                                                                                                                                        mInitialSamples)<<"%\n"; 
     629         
     630         
     631        mStats << 
     632          "#Pass\n" <<mPass<<endl<< 
     633          "#RssPass\n" <<rssPass<<endl<< 
     634          "#Time\n" << TimeDiff(startTime, GetTime())*1e-3<<endl<< 
     635          "#TotalSamples\n" <<totalSamples<<endl<< 
     636          "#RssSamples\n" <<rssSamples<<endl; 
    733637 
    734638 
    735639        if (mUseViewcells) { 
    736            
    737           /// compute view cell contribution of rays 
    738           mViewCellsManager->ComputeSampleContributions(vssRays); 
    739            
    740640          vssRays.PrintStatistics(mStats); 
    741641          mViewCellsManager->PrintPvsStatistics(mStats); 
     
    770670         
    771671        if (mUseImportanceSampling) { 
    772           rssTree->AddRays(vssRays); 
    773            
    774           if (0) { 
    775                 cout<<"############# Rss PVS STAT ##################\n"; 
    776                 cout<<"#AVG_RSS_PVS\n"<<rssTree->GetAvgPvsSize()<<endl; 
    777                 cout<<"#RSS_ROOT_PVS\n"<<rssTree->GetRootPvsSize()<<endl; 
    778           } 
    779            
     672          mRssTree->AddRays(vssRays); 
    780673           
    781674          if (mUpdateSubdivision) { 
    782675                int updatePasses = 1; 
    783676                if (mPass % updatePasses == 0) { 
    784                   int subdivided = rssTree->UpdateSubdivision(); 
     677                  int subdivided = mRssTree->UpdateSubdivision(); 
    785678                  cout<<"subdivided leafs = "<<subdivided<<endl; 
    786                   cout<<"#total leaves = "<<rssTree->stat.Leaves()<<endl; 
     679                  cout<<"#total leaves = "<<mRssTree->stat.Leaves()<<endl; 
    787680                } 
    788681          } 
    789682        } 
    790          
    791  
    792683         
    793684        if (mExportPvs) { 
    794685          char filename[64]; 
    795686          sprintf(filename, "rss-pvs-%04d.x3d", rssPass); 
    796           ExportPvs(filename, rssTree); 
    797         } 
    798  
     687          ExportPvs(filename, mRssTree); 
     688        } 
     689         
    799690         
    800691        if (!mUseImportanceSampling)  
    801692          CLEAR_CONTAINER(vssRays); 
     693        // otherwise the rays get deleted by the rss tree update according to RssTree.maxRays .... 
    802694 
    803695        if (totalSamples >= mRssSamples + mInitialSamples) 
     
    807699        rssPass++; 
    808700        mPass++; 
    809         rssTree->SetPass(mPass); 
     701        mRssTree->SetPass(mPass); 
    810702  } 
    811703   
     
    825717         
    826718  } 
    827  
    828   cerr<<"Deleting RSS tree...\n"; 
    829   delete rssTree; 
    830   cerr<<"Done.\n"; 
     719   
     720  Debug<<"Deleting RSS tree...\n"; 
     721  delete mRssTree; 
     722  Debug<<"Done.\n"; 
    831723 
    832724   
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h

    r537 r563  
    3838 
    3939  ofstream mStats; 
    40  
     40  RssTree *mRssTree; 
    4141 
    4242  // rays cast during the processing 
     
    5656  GetViewpoint(AxisAlignedBox3 *viewSpaceBox); 
    5757 
    58   Vector3 
    59   GetDirection(const Vector3 &viewpoint, 
    60                            AxisAlignedBox3 *viewSpaceBox 
    61                            ); 
    62  
    63   Vector3 
    64   InitialGetDirection(const Vector3 &viewpoint, 
    65                                           AxisAlignedBox3 *viewSpaceBox 
    66                                           ); 
    6758 
    6859  void 
     
    8677         
    8778  virtual bool BuildBspTree() { return false; } 
    88  
     79   
     80  void 
     81  CastRays( 
     82                   SimpleRayContainer &rays, 
     83                   VssRayContainer &vssRays 
     84                   ); 
    8985 
    9086  bool 
     
    132128  ComputeRenderError(); 
    133129 
     130  /** Redefininition of the get sample rays method from the preprocessor */ 
     131  bool 
     132  GenerateRays( 
     133                           const int number, 
     134                           const int sampleType, 
     135                           SimpleRayContainer &rays 
     136                           ); 
     137 
    134138}; 
    135139 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp

    r556 r563  
    20972097   
    20982098  float extendedConvexCombinationProb = 0.0f; //0.7f 
    2099   float silhouetteCheckPercentage = 0.5f; //0.5f 
     2099  float silhouetteCheckPercentage = 0.0f; //0.5f 
    21002100  for (int i=0; generated < numberOfRays && i < numberOfTries; i++) { 
    21012101        bool useExtendedConvexCombination = ((nrays >= 2) && (Random(1.0f) < 
     
    22042204  //  cout<<"desired="<<numberOfRays<<" tries="<<i<<endl; 
    22052205  // assign pdfs to the generated rays 
    2206   float p = (box.GetVolume()*dirBox.GetVolume())/i; 
     2206  float p = 1.0f; //(box.GetVolume()*dirBox.GetVolume())/i; 
     2207  rays.mSumPdf = 0.0f; 
    22072208  for (i=startIndex; i < rays.size(); i++) { 
    22082209        rays[i].mPdf = p; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r492 r563  
    6767  } 
    6868   
    69   mViewCellsManager->ComputeSampleContributions(vssRays); 
     69  mViewCellsManager->ComputeSampleContributions(vssRays, true); 
    7070  CLEAR_CONTAINER(vssRays); 
    7171} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r562 r563  
    171171 
    172172 
    173 void ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays) 
    174 { 
    175         // view cells not yet constructed 
    176         if (!ViewCellsConstructed()) 
    177                 return; 
    178  
    179         VssRayContainer::const_iterator it, it_end = rays.end(); 
    180  
    181         for (it = rays.begin(); it != it_end; ++ it) 
    182         { 
    183                 ComputeSampleContributions(*(*it)); 
    184         } 
     173float 
     174ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays, 
     175                                                                                         const bool addRays 
     176                                                                                         ) 
     177{ 
     178  // view cells not yet constructed 
     179  if (!ViewCellsConstructed()) 
     180        return 0.0f; 
     181   
     182  VssRayContainer::const_iterator it, it_end = rays.end(); 
     183 
     184  float sum = 0.0f; 
     185  for (it = rays.begin(); it != it_end; ++ it) { 
     186        sum += ComputeSampleContributions(*(*it), addRays); 
     187  } 
     188  return sum; 
    185189} 
    186190 
     
    440444} 
    441445 
     446void 
     447ViewCellsManager::AddSampleContributions(const VssRayContainer &rays) 
     448{ 
     449  if (!ViewCellsConstructed()) 
     450        return; 
     451   
     452  VssRayContainer::const_iterator it, it_end = rays.end(); 
     453   
     454  for (it = rays.begin(); it != it_end; ++ it) { 
     455        AddSampleContributions(*(*it)); 
     456  } 
     457} 
    442458 
    443459int ViewCellsManager::GetMinPvsSize() const 
     
    454470 
    455471 
    456 void ViewCellsManager::ComputeSampleContributions(VssRay &ray) 
    457 { 
    458         ViewCellContainer viewcells; 
    459  
    460         ray.mPvsContribution = 0; 
    461         ray.mRelativePvsContribution = 0.0f; 
    462  
    463         // matt TODO: remove this!! 
    464         Ray hray(ray); 
    465         //static Ray hray; 
    466         //hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 
    467          
    468         float tmin = 0, tmax = 1.0; 
    469  
    470         if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 
    471                 return; 
    472  
    473         Vector3 origin = hray.Extrap(tmin); 
    474         Vector3 termination = hray.Extrap(tmax); 
    475  
    476         CastLineSegment(origin, termination, viewcells); 
    477         //Debug << "constribution: " << (int)viewcells.size() << endl; 
    478         // copy viewcells memory efficiently 
    479         const bool storeViewcells = false; 
    480         if (storeViewcells) 
    481         { 
    482                 ray.mViewCells.reserve(viewcells.size()); 
    483                 ray.mViewCells = viewcells; 
    484         } 
    485  
    486         ViewCellContainer::const_iterator it = viewcells.begin(); 
    487  
    488         bool addInPlace = false; 
    489  
    490         if (addInPlace)  
    491         { 
    492                 for (; it != viewcells.end(); ++it) { 
    493                         ViewCell *viewcell = *it; 
    494  
    495                         // if ray not outside of view space 
    496                         float contribution; 
    497                         bool added = 
    498                         viewcell->GetPvs().AddSample(ray.mTerminationObject, 
    499                                                                                  ray.mPdf, 
    500                                                                                  contribution 
    501                                                                                  ); 
    502                         if (added) 
    503                         ray.mPvsContribution++; 
    504  
    505                         ray.mRelativePvsContribution += contribution; 
    506                 } 
    507         }  
    508         else  
    509         { 
    510                 for (; it != viewcells.end(); ++it) { 
    511                         ViewCell *viewcell = *it; 
    512                         // if ray not outside of view space 
    513                         float contribution; 
    514                         if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 
    515                                                                                                                  ray.mPdf, 
    516                                                                                                                  contribution 
    517                                                                                                                  )) 
    518                           ray.mPvsContribution++; 
    519                         ray.mRelativePvsContribution += contribution; 
    520                 } 
    521                  
    522                 for (it = viewcells.begin(); it != viewcells.end(); ++it) { 
    523                   ViewCell *viewcell = *it; 
    524                   // if ray not outside of view space 
    525                   viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 
    526                 } 
    527         } 
     472void 
     473ViewCellsManager::AddSampleContributions(VssRay &ray) 
     474{ 
     475  // assumes viewcells have been stored... 
     476  ViewCellContainer *viewcells = &ray.mViewCells; 
     477  ViewCellContainer::const_iterator it; 
     478  for (it = viewcells->begin(); it != viewcells->end(); ++it) { 
     479        ViewCell *viewcell = *it; 
     480        // if ray not outside of view space 
     481        viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 
     482  } 
     483} 
     484 
     485float 
     486ViewCellsManager::ComputeSampleContributions(VssRay &ray, 
     487                                                                                         const bool addRays 
     488                                                                                         ) 
     489{ 
     490  ViewCellContainer viewcells; 
     491   
     492  ray.mPvsContribution = 0; 
     493  ray.mRelativePvsContribution = 0.0f; 
     494   
     495  // matt TODO: remove this!! 
     496  Ray hray(ray); 
     497  float tmin = 0, tmax = 1.0; 
     498   
     499  //hray.Init(ray.GetOrigin(), ray.GetDir(), Ray::LINE_SEGMENT); 
     500  if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 
     501        return 0.0f; 
     502   
     503  Vector3 origin = hray.Extrap(tmin); 
     504  Vector3 termination = hray.Extrap(tmax); 
     505 
     506  CastLineSegment(origin, 
     507                                  termination, 
     508                                  viewcells); 
     509   
     510  //Debug << "constribution: " << (int)viewcells.size() << endl; 
     511   
     512  // copy viewcells memory efficiently 
     513  const bool storeViewcells = !addRays; 
     514   
     515  if (storeViewcells) 
     516        { 
     517          ray.mViewCells.reserve(viewcells.size()); 
     518          ray.mViewCells = viewcells; 
     519        } 
     520   
     521  ViewCellContainer::const_iterator it = viewcells.begin(); 
     522   
     523   
     524  for (; it != viewcells.end(); ++it) { 
     525        ViewCell *viewcell = *it; 
     526        // if ray not outside of view space 
     527        float contribution; 
     528        if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 
     529                                                                                                 ray.mPdf, 
     530                                                                                                 contribution 
     531                                                                                                 )) 
     532          ray.mPvsContribution++; 
     533        ray.mRelativePvsContribution += contribution; 
     534  } 
     535   
     536  if (addRays) 
     537        for (it = viewcells.begin(); it != viewcells.end(); ++it) { 
     538          ViewCell *viewcell = *it; 
     539          // if ray not outside of view space 
     540          viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 
     541        } 
     542 
     543  return ray.mRelativePvsContribution; 
    528544} 
    529545 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r562 r563  
    6868                @param rays bundle of rays used to find intersections with view cells and  
    6969                adding the contribution 
    70                 @param castRays true if ray should be cast to gain the information, false if rays 
    71                 already hold the view cells intersection information and need not be recast. 
    72                 @param sampleContributions returns the number of sample contributions 
    73                 @param contributingSamples returns the number of contributingSamples 
    74         */ 
    75         void  ComputeSampleContributions(const VssRayContainer &rays); 
    76  
     70                @param addRays true if rays should be added to the PVSs of the viewcells they 
     71                intersect */ 
     72  float ComputeSampleContributions(const VssRayContainer &rays, 
     73                                                                   const bool addContributions = true); 
     74 
     75  /** Add sample contributions to the viewcells they intersect */ 
     76  void AddSampleContributions(const VssRayContainer &rays); 
     77   
    7778 
    7879        /** Computes sample contribution of a simgle ray to the view cells PVS. 
     
    8384                @returns number of sample contributions 
    8485        */ 
    85         virtual void ComputeSampleContributions(VssRay &ray); 
    86    
     86        virtual float ComputeSampleContributions(VssRay &ray, const bool addRays = true); 
     87 
     88  virtual void AddSampleContributions(VssRay &ray); 
     89 
    8790        /** Prints out statistics of the view cells. 
    8891        */ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r556 r563  
    2525#       type vss 
    2626        type rss 
    27         detectEmptyViewSpace true 
    28 } 
     27        detectEmptyViewSpace false 
     28        pvsRenderErrorSamples 10000 
     29 
     30} 
     31 
    2932 
    3033VssPreprocessor { 
     
    5356        maxStaticMemory 100 
    5457 
    55         splitType regular 
     58#       splitType regular 
    5659#       splitType heuristic 
    57 #       splitType hybrid 
     60        splitType hybrid 
    5861        splitUseOnlyDrivingAxis true 
    5962 
     
    6972 
    7073RssPreprocessor { 
    71         samplesPerPass  100000 
    72         initialSamples 100000 
    73         vssSamples 10000 
    74         vssSamplesPerPass 100000 
     74        samplesPerPass 500000 
     75        initialSamples 1000000 
     76        vssSamples 15000000 
     77        vssSamplesPerPass 1000000 
    7578        useImportanceSampling true 
    7679 
     
    8790        useViewcells true 
    8891        updateSubdivision true 
    89         loadInitialSamples true 
     92        loadInitialSamples false 
    9093        storeInitialSamples false 
    9194} 
     
    102105        maxCostRatio 1.0 
    103106        maxRayContribution 0.5 
    104         maxRays         1000000 
     107        maxRays         5000000 
    105108        maxTotalMemory  200 
    106109        maxStaticMemory 100 
    107110 
    108         splitType regular 
     111#       splitType regular 
    109112#       splitType heuristic 
    110 #       splitType hybrid 
    111         splitUseOnlyDrivingAxis true 
     113        splitType hybrid 
     114        splitUseOnlyDrivingAxis false 
    112115        importanceBasedCost false 
    113116 
     
    166169} 
    167170 
     171 
    168172ViewCells { 
    169173        loadFromFile true 
     174        exportToFile false 
    170175        #type kdTree 
    171176        #type vspKdTree 
    172         # type bspTree 
     177        #type bspTree 
    173178        type vspBspTree 
    174179         
     
    176181         
    177182        height 5.0 
    178         maxViewCells 500 
    179         maxPvs 200 
    180          
    181          
    182 PostProcess { 
    183                 minPvsDif 100 
    184                 minPvs 10 
    185                 maxPvs 150 
     183        maxViewCells 100000 
     184        #percentage of total visible objects where pvs is considered invalid 
     185        maxPvsRatio 0.05 
     186                 
     187        delayedConstruction true 
     188                 
     189                 
     190        PostProcess { 
    186191                # how much samples are used for post processing 
    187                 samples 100000 
    188         } 
    189  
    190                 Visualization { 
     192                samples 200000 
     193        } 
     194 
     195        Visualization { 
    191196                # how much samples we use for visualization 
    192197                samples 5000 
     
    196201                colorCode Random 
    197202                exportRays false 
    198                 exportGeometry true 
    199         } 
    200          
    201         filename ../data/soda/viewcells_soda5-2.xml 
    202 #       filename ../data/atlanta/viewcells_atlanta2.xml 
     203                exportGeometry false 
     204        } 
     205         
     206#       filename ../data/soda/viewcells_soda5-2.xml 
     207        filename ../data/atlanta/viewcells_atlanta2.xml 
    203208#       filename ../data/atlanta/atlanta_viewcells_large.x3d 
    204209#       filename ../data/vienna/viewcells-25-sel.x3d 
    205210#       filename ../data/vienna/viewcells-25.x3d 
    206211#       filename ../data/vienna/viewcells-large-sel.x3d 
     212#       filename ../scripts/viewcells_vienna.xml 
     213 
     214 
    207215} 
    208216 
     
    252260        } 
    253261} 
     262 
    254263 
    255264VspBspTree { 
     
    309318        } 
    310319         
    311         PostProcess { 
    312                 maxCostRatio 0.1 
    313                 minViewCells 500 
    314                 maxPvsSize   1000 
    315                 useRaysForMerge true 
    316         } 
    317 } 
     320} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro

    r556 r563  
    1717 
    1818# debuc config 
    19 CONFIG          += console warn_off thread debug qt 
     19CONFIG          += console warn_off thread release qt 
    2020 
    2121# RELEASE CONFIG 
Note: See TracChangeset for help on using the changeset viewer.