Changeset 467
- Timestamp:
- 12/15/05 15:18:15 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r466 r467 12 12 #include "RenderSimulator.h" 13 13 14 static bool useViewSpaceBox = true;14 static bool useViewSpaceBox = false; 15 15 static bool use2dSampling = false; 16 16 static bool fromBoxVisibility = false; … … 219 219 220 220 cout<< 221 "# AVG_PVS_SIZE\n"<<avgPvsSize<<endl<<222 "# AVG_RAYS\n"<<avgRays<<endl<<223 "# AVG_RAY_CONTRIB\n"<<avgRayContribution<<endl<<224 "# AVG_PVS_ENTROPY\n"<<avgPvsEntropy<<endl<<225 "# AVG_RAY_LENGTH_ENTROPY\n"<<avgRayLengthEntropy<<endl<<226 "# AVG_IMPORTANCE\n"<<avgImportance<<endl;221 "#RSS_AVG_PVS_SIZE\n"<<avgPvsSize<<endl<< 222 "#RSS_AVG_RAYS\n"<<avgRays<<endl<< 223 "#RSS_AVG_RAY_CONTRIB\n"<<avgRayContribution<<endl<< 224 "#RSS_AVG_PVS_ENTROPY\n"<<avgPvsEntropy<<endl<< 225 "#RSS_AVG_RAY_LENGTH_ENTROPY\n"<<avgRayLengthEntropy<<endl<< 226 "#RSS_AVG_IMPORTANCE\n"<<avgImportance<<endl; 227 227 228 228 if (0) { … … 466 466 } 467 467 468 mPass++; 469 470 int pvsSize = 0; 468 471 469 float avgRayContrib = (passContributingSamples > 0) ? 472 470 passSampleContributions/(float)passContributingSamples : 0; … … 475 473 cout << "#TotalSamples=" << totalSamples/1000 476 474 << "k #SampleContributions=" << passSampleContributions << " (" 477 << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 478 << pvsSize/(float)mObjects.size() << endl 479 << "avg ray contrib=" << avgRayContrib << endl; 475 << 100*passContributingSamples/(float)passSamples<<"%)" 476 << "avgcontrib=" << avgRayContrib << endl; 480 477 481 478 mStats << … … 485 482 "#SampleContributions\n" << passSampleContributions << endl << 486 483 "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl << 487 "#AvgPVS\n"<< pvsSize/(float)mObjects.size() << endl <<488 484 "#AvgRayContrib\n" << avgRayContrib << endl; 485 486 mPass++; 487 489 488 } 490 489 … … 499 498 } 500 499 501 if (mUseViewcells) 500 if (mUseViewcells) { 502 501 // construct view cells 503 502 mViewCellsManager->Construct(mObjects, mVssRays, mViewSpaceBox); 503 504 VssRayContainer selectedRays; 505 int desired = Max( 506 mViewCellsManager->GetPostProcessSamples(), 507 mViewCellsManager->GetVisualizationSamples()); 508 float p = desired/(float)mVssRays.size(); 509 // rssTree->CollectRays(storedRays, desired); 510 for (int i=0; i < mVssRays.size(); i++) { 511 if (Random(1.0f) < p) 512 selectedRays.push_back(mVssRays[i]); 513 } 514 //-- post process view cells 515 mViewCellsManager->PostProcess(mObjects, selectedRays); 516 517 //-- several visualizations and statistics 518 mViewCellsManager->PrintStatistics(Debug); 519 520 if (1) 521 mViewCellsManager->Visualize(mObjects, selectedRays); 522 523 CLEAR_CONTAINER(storedRays); 524 } 525 504 526 505 527 rssTree = new RssTree; 506 528 507 if (fromBoxVisibility) 508 rssTree->Construct(mVssRays, mViewSpaceBox); 509 else 510 rssTree->Construct(mVssRays, NULL); 511 512 cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 513 514 if (mExportRssTree) { 515 ExportRssTree("rss-tree-100.x3d", rssTree, Vector3(1,0,0)); 516 ExportRssTree("rss-tree-001.x3d", rssTree, Vector3(0,0,1)); 517 ExportRssTree("rss-tree-101.x3d", rssTree, Vector3(1,0,1)); 518 ExportRssTree("rss-tree-101m.x3d", rssTree, Vector3(-1,0,-1)); 519 ExportRssTreeLeaves(rssTree, 10); 520 } 521 522 if (mExportPvs) { 523 ExportPvs("rss-pvs-initial.x3d", rssTree); 524 } 525 529 if (mUseImportanceSampling) { 530 531 if (fromBoxVisibility) 532 rssTree->Construct(mVssRays, mViewSpaceBox); 533 else 534 rssTree->Construct(mVssRays, NULL); 535 cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 536 537 if (mExportRssTree) { 538 ExportRssTree("rss-tree-100.x3d", rssTree, Vector3(1,0,0)); 539 ExportRssTree("rss-tree-001.x3d", rssTree, Vector3(0,0,1)); 540 ExportRssTree("rss-tree-101.x3d", rssTree, Vector3(1,0,1)); 541 ExportRssTree("rss-tree-101m.x3d", rssTree, Vector3(-1,0,-1)); 542 ExportRssTreeLeaves(rssTree, 10); 543 } 544 545 if (mExportPvs) { 546 ExportPvs("rss-pvs-initial.x3d", rssTree); 547 } 548 } 549 526 550 // viewcells->UpdatePVS(newVssRays); 527 551 528 int samples = 0;529 int pass = 0;552 int rssPass = 0; 553 int rssSamples = 0; 530 554 while (1) { 531 555 int num = mRssSamplesPerPass; … … 546 570 for (int i=0; i < rays.size(); i++) 547 571 CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays); 548 572 573 574 totalSamples+=num; 575 rssSamples+=num; 576 577 mStats << 578 "#Pass\n" <<mPass<<endl<< 579 "#RssPass\n" <<rssPass<<endl<< 580 "#Time\n" << TimeDiff(startTime, GetTime())*1e-3<<endl<< 581 "#TotalSamples\n" <<totalSamples<<endl<< 582 "#RssSamples\n" <<rssSamples<<endl; 583 549 584 if (mUseViewcells) { 550 585 586 /// compute view cell contribution of rays 587 mViewCellsManager->ComputeSampleContributions(vssRays); 551 588 552 /// compute view cell contribution of rays 553 mViewCellsManager->ComputeSampleContributions(vssRays 554 ); 589 vssRays.PrintStatistics(mStats); 590 mViewCellsManager->PrintPvsStatistics(mStats); 591 } 592 593 // add rays to the tree after the viewcells have been cast to have their contributions 594 // already when adding into the tree 595 // do not add those rays which have too low or no contribution.... 596 597 if (mUseImportanceSampling) { 598 rssTree->AddRays(vssRays); 555 599 600 if (0) { 601 cout<<"############# Rss PVS STAT ##################\n"; 602 cout<<"#AVG_RSS_PVS\n"<<rssTree->GetAvgPvsSize()<<endl; 603 cout<<"#RSS_ROOT_PVS\n"<<rssTree->GetRootPvsSize()<<endl; 604 } 556 605 557 float pvs = rssTree->GetAvgPvsSize(); 558 cout<<"*****************************\n"; 559 cout<<samples<<" avgPVS ="<<pvs<<endl; 560 cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 561 cout<<"*****************************\n"; 562 } 563 564 565 566 rssTree->AddRays(vssRays); 567 568 if (mUpdateSubdivision) { 569 int subdivided = rssTree->UpdateSubdivision(); 570 cout<<"subdivided leafs = "<<subdivided<<endl; 571 cout<<"#total leaves = "<<rssTree->stat.Leaves()<<endl; 572 } 573 574 if (mUseViewcells) { 575 // float avgPvs = GetAvgPvsSize(rssTree, kdViewcells); 576 // cout<<"Average PVS size = "<<avgPvs<<endl; 577 } 578 606 if (mUpdateSubdivision) { 607 int subdivided = rssTree->UpdateSubdivision(); 608 cout<<"subdivided leafs = "<<subdivided<<endl; 609 cout<<"#total leaves = "<<rssTree->stat.Leaves()<<endl; 610 } 611 } 612 579 613 if (mExportRays) { 580 614 char filename[64]; 581 615 if (mUseImportanceSampling) 582 sprintf(filename, "rss-rays-i%04d.x3d", pass);616 sprintf(filename, "rss-rays-i%04d.x3d", rssPass); 583 617 else 584 sprintf(filename, "rss-rays-%04d.x3d", pass);618 sprintf(filename, "rss-rays-%04d.x3d", rssPass); 585 619 586 620 ExportRays(filename, vssRays, mExportNumRays); 587 621 } 588 622 589 samples+=num;590 591 623 592 624 if (mExportPvs) { 593 625 char filename[64]; 594 sprintf(filename, "rss-pvs-%04d.x3d", pass);626 sprintf(filename, "rss-pvs-%04d.x3d", rssPass); 595 627 ExportPvs(filename, rssTree); 596 628 } 597 629 598 if ( samples >= mRssSamples)630 if (totalSamples >= mRssSamples + mInitialSamples) 599 631 break; 600 632 601 633 602 pass++; 634 rssPass++; 635 mPass++; 603 636 } 604 637 605 638 if (mUseViewcells) { 606 639 607 VssRayContainer storedRays;608 rssTree->CollectRays(storedRays, Max(609 mViewCellsManager->GetPostProcessSamples(),610 mViewCellsManager->GetVisualizationSamples()));611 612 //-- post process view cells613 mViewCellsManager->PostProcess(mObjects, storedRays);614 615 //-- several visualizations and statistics616 mViewCellsManager->PrintStatistics(Debug);617 618 mViewCellsManager->Visualize(mObjects, storedRays);619 620 CLEAR_CONTAINER(storedRays);621 640 622 641 //-- render simulation after merge -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r466 r467 208 208 } 209 209 210 void 211 ViewCellsManager::GetPvsStatistics(PvsStatistics &stat) 212 { 213 ViewCellContainer::const_iterator it = mViewCells.begin(); 214 stat.viewcells = 0; 215 stat.minPvs = 100000000; 216 stat.maxPvs = 0; 217 stat.avgPvs = 0.0f; 218 219 for (; it != mViewCells.end(); ++it) { 220 ViewCell *viewcell = *it; 221 int pvsSize = viewcell->GetPvs().GetSize(); 222 if ( pvsSize < stat.minPvs) 223 stat.minPvs = pvsSize; 224 if (pvsSize > stat.maxPvs) 225 stat.maxPvs = pvsSize; 226 stat.avgPvs += pvsSize; 227 stat.viewcells++; 228 } 229 if (stat.viewcells) 230 stat.avgPvs/=stat.viewcells; 231 } 232 233 void 234 ViewCellsManager::PrintPvsStatistics(ostream &s) 235 { 236 s<<"############# Viewcell PVS STAT ##################\n"; 237 PvsStatistics pvsStat; 238 GetPvsStatistics(pvsStat); 239 s<<"#AVG_PVS\n"<<pvsStat.avgPvs<<endl; 240 s<<"#MAX_PVS\n"<<pvsStat.maxPvs<<endl; 241 s<<"#MIN_PVS\n"<<pvsStat.minPvs<<endl; 242 } 243 210 244 /**********************************************************************/ 211 245 /* BspViewCellsManager implementation */ … … 260 294 sampleRays.push_back(new Ray(*rays[i])); 261 295 262 if (mViewCells.empty()) // no view cells loaded 263 mBspTree->Construct(objects, sampleRays); 264 else 265 mBspTree->Construct(mViewCells); 266 296 if (mViewCells.empty()) { // no view cells loaded 297 mBspTree->Construct(objects, sampleRays); 298 mBspTree->CollectViewCells(mViewCells); 299 } else 300 mBspTree->Construct(mViewCells); 301 302 267 303 Debug << mBspTree->GetStatistics() << endl; 268 304 … … 280 316 viewcells 281 317 ); 318 319 ray.mPvsContribution = 0; 320 ray.mRelativePvsContribution = 0.0f; 282 321 283 322 ViewCellContainer::const_iterator it = viewcells.begin(); … … 770 809 } 771 810 811 772 812 /**********************************************************************/ 773 813 /* KdViewCellsManager implementation */ … … 1186 1226 1187 1227 mVspBspTree->Construct(sampleRays); 1228 mVspBspTree->CollectViewCells(mViewCells); 1188 1229 1189 1230 Debug << mVspBspTree->GetStatistics() << endl; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r466 r467 29 29 30 30 public: 31 struct PvsStatistics { 32 int minPvs; 33 int maxPvs; 34 float avgPvs; 35 int viewcells; 36 }; 31 37 32 38 /// view cell container types … … 165 171 ) = 0; 166 172 173 virtual void GetPvsStatistics(PvsStatistics &stat); 174 175 virtual void 176 PrintPvsStatistics(ostream &s); 167 177 168 178 protected: … … 183 193 184 194 /// Loaded view cells 185 195 ViewCellContainer mViewCells; 186 196 187 197 /// maximum number of samples taken for construction of the view cells … … 234 244 ); 235 245 246 236 247 protected: 237 248 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.cpp
r464 r467 194 194 } 195 195 } 196 197 198 void 199 VssRayContainer::PrintStatistics(ostream &s) 200 { 201 202 VssRayContainer::const_iterator it = begin(), it_end = end(); 203 int sumContributions = 0; 204 float sumRelContributions = 0.0f; 205 206 for (; it != it_end; ++it) { 207 VssRay *ray = *it; 208 sumContributions += ray->mPvsContribution; 209 sumRelContributions += ray->mRelativePvsContribution; 210 } 211 212 s<<"##### VSS RAY STAT ##########\n"; 213 s<<"#RAYS\n"<<size()<<endl; 214 s<<"#AVG_RAY_PVS_CONTRIBUTION\n"<<sumContributions/(float)size()<<endl; 215 s<<"#AVG_RAY_RELATIVE_PVS_CONTRIBUTION\n"<<sumRelContributions/ 216 (float)size()<<endl; 217 218 } -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h
r464 r467 269 269 }; 270 270 271 typedef vector<VssRay *> VssRayContainer; 271 struct VssRayContainer : public vector<VssRay *> 272 { 273 void PrintStatistics(ostream &s); 274 }; 272 275 273 276 -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r464 r467 66 66 initialSamples 500000 67 67 vssSamples 10000000 68 vssSamplesPerPass 50000068 vssSamplesPerPass 100000 69 69 useImportanceSampling true 70 70 … … 76 76 } 77 77 78 useViewcells false78 useViewcells true 79 79 updateSubdivision false 80 80 } … … 156 156 loadFromFile false 157 157 #type kdTree 158 type vspKdTree158 #type vspKdTree 159 159 #type bspTree 160 #type vspBspTree160 type vspBspTree 161 161 162 162 #type sceneDependent … … 339 339 Termination { 340 340 # parameters used for autopartition 341 minRays 200341 minRays 1000 342 342 minPolygons -1 343 343 maxDepth 40 344 minPvs 100345 minArea 0.01344 minPvs 20 345 minArea 200000 346 346 maxRayContribution 0.005 347 347 #maxAccRayLength 100
Note: See TracChangeset
for help on using the changeset viewer.