Ignore:
Timestamp:
01/10/07 21:32:50 (18 years ago)
Author:
bittner
Message:

samplign preprocessor updates, merge

File:
1 edited

Legend:

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

    r1900 r1966  
    2020{ 
    2121  // this should increase coherence of the samples 
    22   Environment::GetSingleton()->GetIntValue("SamplingPreprocessor.samplesPerPass", mSamplesPerPass); 
    23   Environment::GetSingleton()->GetIntValue("SamplingPreprocessor.totalSamples", mTotalSamples); 
    2422   
    2523} 
     
    8785  int intersectables, faces; 
    8886  mSceneGraph->GetStatistics(intersectables, faces); 
    89   HaltonSequence halton; 
     87  HaltonSequence posHalton; 
    9088   
    9189  int samples = 0; 
    92   int i=0; 
     90  int rssSamples = 0; 
     91 
     92  map<ViewCell *, HaltonSequence> dirHalton; 
     93   
    9394  while (samples < mTotalSamples) { 
    94         for (i=0; i < mSamplesPerPass;) { 
     95        for (int i=0; i < mSamplesPerEvaluation;) { 
    9596          SimpleRayContainer rays; 
    9697          VssRayContainer vssRays; 
    97           vector<ViewCell *> viewcells; 
     98          //      vector<ViewCell *> viewcells; 
     99           
     100          float r[5]; 
     101          Vector3 origin, direction; 
     102          posHalton.GetNext(3, r); 
     103 
     104          mViewCellsManager->GetViewPoint(origin, Vector3(r[0], r[1], r[2])); 
     105          ViewCell *viewcell = mViewCellsManager->GetViewCell(origin); 
     106           
     107          if (!viewcell || !viewcell->GetValid()) 
     108                continue; 
     109           
    98110          for (; rays.size() < 16; ) { 
    99                 if (i%10000 == 0) 
     111                if (i%100000 == 0) 
    100112                  cout<<"+"; 
    101  
    102                 float r[5]; 
    103                 halton.GetNext(5, r); 
    104                 Vector3 origin, direction; 
    105                 mViewCellsManager->GetViewPoint(origin, Vector3(r[0], r[1], r[2])); 
    106113                 
    107                 direction = UniformRandomVector(r[3],r[4]); 
    108                 ViewCell *viewcell = mViewCellsManager->GetViewCell(origin); 
     114                //              dirHalton.GetNext(2, r); 
     115                dirHalton[viewcell].GetNext(2, r); 
     116                direction = UniformRandomVector(r[0],r[1]); 
     117                //direction = UniformRandomVector(); 
    109118                 
    110                 if (viewcell && viewcell->GetValid()) { 
    111                   viewcells.push_back(viewcell); 
    112                   // cast rays in both directions to make the number of samples comparable 
    113                   // with the global sampling method which also casts a "double" ray per sample 
    114                   rays.push_back(SimpleRay(origin, 
    115                                                                    direction, 
    116                                                                    SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, 
    117                                                                    1.0f)); 
    118                   i++; 
    119                   samples++; 
    120                 } 
     119                //              viewcells.push_back(viewcell); 
     120                // cast rays in both directions to make the number of samples comparable 
     121                // with the global sampling method which also casts a "double" ray per sample 
     122                rays.push_back(SimpleRay(origin, 
     123                                                                 direction, 
     124                                                                 SamplingStrategy::DIRECTION_BASED_DISTRIBUTION, 
     125                                                                 1.0f)); 
     126                i++; 
     127                samples++; 
    121128          } 
    122129           
     
    124131                           vssRays, 
    125132                           true, 
    126                            false); 
    127  
    128           if (vssRays.size()!=32) { 
    129                 cerr<<"wrong number of rays "<<(int)vssRays.size()<<endl; 
    130                 exit(1); 
    131           } 
    132                  
     133                           true); 
     134           
     135          //      if (vssRays.size()!=32) { 
     136          //            cerr<<"wrong number of rays "<<(int)vssRays.size()<<endl; 
     137          //            exit(1); 
     138          //      } 
     139 
     140          rssSamples+=vssRays.size(); 
    133141          for (int j=0; j < vssRays.size(); j++) 
    134142                if (vssRays[j]->mFlags & VssRay::Valid) { 
     
    137145                  if (obj) { 
    138146                        // if ray not outside of view space 
    139                         float contribution; 
    140                         int pvsContribution = 0; 
    141                         float relativePvsContribution = 0; 
    142147                        float pdf = 1.0f; 
    143                         ViewCell *viewcell = viewcells[j/2]; 
    144                         if (viewcell->GetPvs().GetSampleContribution(obj, 
    145                                                                                                                  pdf, 
    146                                                                                                                  contribution))  
    147                           ++pvsContribution; 
    148                         relativePvsContribution += contribution; 
    149                         viewcell->GetPvs().AddSample(obj, pdf); 
     148                        //                      ViewCell *viewcell = viewcells[j/2]; 
     149 
     150                        ObjectPvs &pvs = viewcell->GetPvs(); 
     151                        pvs.AddSampleDirtyCheck(obj, pdf); 
     152                         
     153                        if (pvs.RequiresResort())  { 
     154                          pvs.SimpleSort(); 
     155                        } 
    150156                  } 
    151157                } 
    152158           
    153159          CLEAR_CONTAINER(vssRays); 
    154  
     160           
    155161          if (samples > mTotalSamples) 
    156162                break; 
     
    166172        mStats << 
    167173          "#Time\n" << TimeDiff(startTime, GetTime())*1e-3<<endl<< 
    168           "#TotalSamples\n" <<samples<<endl; 
    169  
     174          "#TotalSamples\n" <<samples<<endl<< 
     175          "#RssSamples\n" <<rssSamples<<endl; 
     176                   
    170177        mViewCellsManager->PrintPvsStatistics(mStats); 
    171178        // ComputeRenderError(); 
Note: See TracChangeset for help on using the changeset viewer.