- Timestamp:
- 11/10/05 09:55:50 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r387 r401 39 39 VssPreprocessor::CastRay( 40 40 Vector3 &viewPoint, 41 Vector3 &direction 41 Vector3 &direction, 42 VssRayContainer &vssRays 42 43 ) 43 44 { … … 60 61 box.ComputeMinMaxT(ray, &tmin, &tmax); 61 62 if (tmax > bsize) { 62 cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl;63 cerr<<"ray"<<ray<<endl;63 // cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 64 // cerr<<"ray"<<ray<<endl; 64 65 } 65 66 pointA = ray.Extrap(tmax); … … 85 86 box.ComputeMinMaxT(ray, &tmin, &tmax); 86 87 if (tmax > bsize) { 87 cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl;88 cerr<<"ray"<<ray<<endl;88 // cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 89 // cerr<<"ray"<<ray<<endl; 89 90 } 90 91 … … 108 109 objectB, 109 110 objectA); 110 mVssRays.push_back(vssRay);111 vssRays.push_back(vssRay); 111 112 hits ++; 112 113 } … … 117 118 objectA, 118 119 objectB); 119 mVssRays.push_back(vssRay);120 vssRays.push_back(vssRay); 120 121 hits ++; 121 122 } … … 150 151 } 151 152 153 int 154 VssPreprocessor::RandomizedImportanceSampling(VssTree *vssTree, 155 const int desiredSamples) 156 { 157 float minRayContribution; 158 float maxRayContribution; 159 float avgRayContribution; 160 161 vssTree->GetRayContributionStatistics(minRayContribution, 162 maxRayContribution, 163 avgRayContribution); 164 165 cout<< 166 "#MIN_RAY_CONTRIB\n"<<minRayContribution<<endl<< 167 "#MAX_RAY_CONTRIB\n"<<maxRayContribution<<endl<< 168 "#AVG_RAY_CONTRIB\n"<<avgRayContribution<<endl; 169 170 float p = desiredSamples/(float)(avgRayContribution*vssTree->stat.Leaves()); 171 SimpleRayContainer rays; 172 int num = vssTree->GenerateRays(p, rays); 173 cout<<"Generated "<<num<<" rays."<<endl; 174 175 VssRayContainer vssRays; 176 177 for (int i=0; i < rays.size(); i++) 178 CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays); 179 180 vssTree->AddRays(vssRays); 181 return num; 182 } 152 183 153 184 … … 175 206 } 176 207 177 bool useViewSpaceBox = true;208 bool useViewSpaceBox = false; 178 209 if (useViewSpaceBox) 179 210 viewSpaceBox = &box; 180 211 212 VssTree *vssTree = NULL; 213 181 214 while (totalSamples < mTotalSamples) { 182 215 int passContributingSamples = 0; … … 193 226 Vector3 direction = GetDirection(viewpoint); 194 227 195 sampleContributions = CastRay(viewpoint, direction );228 sampleContributions = CastRay(viewpoint, direction, mVssRays); 196 229 197 230 … … 226 259 "#AvgPVS\n"<< pvsSize/(float)mObjects.size() << endl << 227 260 "#AvgRayContrib\n" << avgRayContrib << endl; 261 262 263 264 228 265 } 229 266 … … 257 294 cout<<"done."<<endl<<flush; 258 295 259 VssTree *vssTree = new VssTree; 260 296 297 298 299 vssTree = new VssTree; 300 261 301 vssTree->Construct(mVssRays, viewSpaceBox); 262 302 263 303 cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 264 265 266 304 305 306 int samples = 0; 307 for (int i=0; i < 50; i++) { 308 int num = 100000; 309 if (0) { 310 VssRayContainer vssRays; 311 for (int j=0; j < num; j++) { 312 Vector3 viewpoint = GetViewpoint(viewSpaceBox); 313 Vector3 direction = GetDirection(viewpoint); 314 CastRay(viewpoint, direction, vssRays); 315 } 316 vssTree->AddRays(vssRays); 317 } else { 318 num = RandomizedImportanceSampling(vssTree, num); 319 } 320 samples+=num; 321 float pvs = vssTree->GetAvgPvsSize(); 322 cout<<samples<<" avgPVS ="<<pvs<<endl; 323 } 324 325 delete vssTree; 326 267 327 return true; 268 328 }
Note: See TracChangeset
for help on using the changeset viewer.