- Timestamp:
- 01/10/07 21:32:50 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
r1900 r1966 20 20 { 21 21 // this should increase coherence of the samples 22 Environment::GetSingleton()->GetIntValue("SamplingPreprocessor.samplesPerPass", mSamplesPerPass);23 Environment::GetSingleton()->GetIntValue("SamplingPreprocessor.totalSamples", mTotalSamples);24 22 25 23 } … … 87 85 int intersectables, faces; 88 86 mSceneGraph->GetStatistics(intersectables, faces); 89 HaltonSequence halton;87 HaltonSequence posHalton; 90 88 91 89 int samples = 0; 92 int i=0; 90 int rssSamples = 0; 91 92 map<ViewCell *, HaltonSequence> dirHalton; 93 93 94 while (samples < mTotalSamples) { 94 for (i =0; i < mSamplesPerPass;) {95 for (int i=0; i < mSamplesPerEvaluation;) { 95 96 SimpleRayContainer rays; 96 97 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 98 110 for (; rays.size() < 16; ) { 99 if (i%10000 == 0)111 if (i%100000 == 0) 100 112 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]));106 113 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(); 109 118 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++; 121 128 } 122 129 … … 124 131 vssRays, 125 132 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(); 133 141 for (int j=0; j < vssRays.size(); j++) 134 142 if (vssRays[j]->mFlags & VssRay::Valid) { … … 137 145 if (obj) { 138 146 // if ray not outside of view space 139 float contribution;140 int pvsContribution = 0;141 float relativePvsContribution = 0;142 147 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 } 150 156 } 151 157 } 152 158 153 159 CLEAR_CONTAINER(vssRays); 154 160 155 161 if (samples > mTotalSamples) 156 162 break; … … 166 172 mStats << 167 173 "#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 170 177 mViewCellsManager->PrintPvsStatistics(mStats); 171 178 // ComputeRenderError();
Note: See TracChangeset
for help on using the changeset viewer.