- Timestamp:
- 12/05/05 20:33:53 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r451 r452 19 19 20 20 Preprocessor { 21 type sampling22 #type vss21 # type sampling 22 type vss 23 23 # type rss 24 24 } 25 25 26 26 VssPreprocessor { 27 samplesPerPass 10000 028 initialSamples 50000029 vssSamples 100000030 vssSamplesPerPass 5000027 samplesPerPass 10000 28 initialSamples 100000 29 vssSamples 300000 30 vssSamplesPerPass 10000 31 31 useImportanceSampling true 32 32 } … … 64 64 RssPreprocessor { 65 65 samplesPerPass 100000 66 initialSamples 50000067 vssSamples 500000066 initialSamples 400000 67 vssSamples 1000000 68 68 vssSamplesPerPass 100000 69 69 useImportanceSampling true … … 279 279 280 280 Construction { 281 samples 100000281 samples 300000 282 282 } 283 283 284 284 Termination { 285 285 maxDepth 40 286 minPvs 50287 minRays 1 286 minPvs 40 287 minRays 100 288 288 minSize 0.1 289 289 maxCostRatio 999.0 … … 330 330 Termination { 331 331 # parameters used for autopartition 332 minRays 200332 minRays 100 333 333 minPolygons -1 334 maxDepth 40334 maxDepth 30 335 335 minPvs 100 336 336 minArea 0.01 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r451 r452 10 10 #include "RssTree.h" 11 11 #include "ViewCellsManager.h" 12 13 static bool useViewSpaceBox = true;//true; 12 #include "RenderSimulator.h" 13 14 static bool useViewSpaceBox = true; 14 15 static bool use2dSampling = false; 15 16 static bool fromBoxVisibility = true; … … 423 424 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 424 425 425 CastRay(viewpoint, direction, mVssRays);426 sampleContributions = CastRay(viewpoint, direction, mVssRays); 426 427 427 428 … … 587 588 cout<<"*****************************\n"; 588 589 cout<<samples<<" avgPVS ="<<pvs<<endl; 590 cout<<"sample contributions ="<<sampleContributions<<endl; 591 cout<<"contributing sample ="<<contributingSamples<<endl; 589 592 cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 590 593 cout<<"*****************************\n"; … … 603 606 } 604 607 608 //-- post process view cells 609 mViewCellsManager->PostProcess(mObjects, storedRays); 610 611 //-- several visualizations and statistics 612 Debug << "===== Final view cells statistics ==========" << endl; 613 614 mViewCellsManager->PrintStatistics(Debug); 615 616 //-- render simulation after merge 617 cout << "\nevaluating render time of final view cells ... "; 618 619 const SimulationStatistics ss = mViewCellsManager->SimulateRendering(); 620 621 cout << " finished" << endl; 622 623 cout << ss << endl; 624 Debug << ss << endl; 625 626 mViewCellsManager->Visualize(mObjects, storedRays); 627 605 628 delete rssTree; 606 629 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r451 r452 390 390 delete exporter; 391 391 } 392 393 //-- post process view cells 392 393 // construct view cells if not already constructed 394 if (!mViewCellsManager->ViewCellsConstructed()) 395 mViewCellsManager->Construct(objects, mVssSampleRays); 396 394 397 mViewCellsManager->PostProcess(objects, mSampleRays); 395 396 398 397 399 //-- several visualizations and statistics 398 400 Debug << "===== Final view cells statistics ==========" << endl; 401 402 mViewCellsManager->PrintStatistics(Debug); 403 399 404 //-- render simulation after merge 400 405 cout << "\nevaluating bsp view cells render time after merge ... "; … … 406 411 Debug << ss << endl; 407 412 408 409 413 mViewCellsManager->Visualize(objects, mSampleRays); 410 414 … … 423 427 if (!mViewCellsManager->ViewCellsConstructed()) 424 428 { 425 RayContainer::const_iterator it, it_end = newRays.end(); 426 427 if ((int)mVssSampleRays.size() < 428 mViewCellsManager->GetConstructionSamples()) 429 if ((int)mVssSampleRays.size() < mViewCellsManager->GetConstructionSamples()) 429 430 { 431 RayContainer::const_iterator it, it_end = newRays.end(); 432 430 433 for (it = newRays.begin(); it != it_end; ++ it) 431 {432 434 mVssSampleRays.push_back(new VssRay(*(*it))); 433 }434 435 } 435 436 else … … 443 444 } 444 445 // Need rays (with ordered intersections) for post processing => collect new rays 445 elseif (((int)mSampleRays.size() < mViewCellsManager->GetPostProcessSamples()) ||446 446 if (((int)mSampleRays.size() < mViewCellsManager->GetPostProcessSamples()) || 447 ((int)mSampleRays.size() < mViewCellsManager->GetVisualizationSamples())) 447 448 { 448 449 RayContainer::const_iterator it, it_end = newRays.end(); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r450 r452 1589 1589 1590 1590 // give penalty to unbalanced split 1591 if ( 1)1591 if (0) 1592 1592 if (((pFront * 0.2 + Limits::Small) > pBack) || 1593 1593 (pFront < (pBack * 0.2 + Limits::Small))) -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r449 r452 78 78 RayContainer::const_iterator it, it_end = rays.end(); 79 79 80 sampleContributions = 0; 81 contributingSamples = 0; 82 80 83 for (it = rays.begin(); it != it_end; ++ it) 81 84 { … … 329 332 } 330 333 331 332 334 //-- post processing of bsp view cells 333 335 int vcSize = 0; … … 420 422 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 421 423 422 // statistics after post process423 vcStats.Reset();424 mBspTree->EvaluateViewCellsStats(vcStats);425 Debug << "post processed view cell partition:\n" << vcStats << endl;426 427 424 return merged; 428 425 } … … 775 772 } 776 773 777 774 void BspViewCellsManager::PrintStatistics(ostream &s) const 775 { 776 BspViewCellsStatistics vcStats; 777 mBspTree->EvaluateViewCellsStats(vcStats); 778 s << vcStats << endl; 779 } 778 780 779 781 /**********************************************************************/ … … 963 965 964 966 967 void KdViewCellsManager::PrintStatistics(ostream &s) const 968 { 969 } 965 970 966 971 /**********************************************************************/ … … 983 988 if (ViewCellsConstructed()) 984 989 return 0; 985 990 991 VssRayContainer sampleRays; 992 993 int limit = min (mConstructionSamples, (int)rays.size()); 994 995 for (int i = 0; i < limit; ++ i) 996 sampleRays.push_back(rays[i]); 997 998 Debug << "constructing vsp kd tree using " << (int)sampleRays.size() << " samples" << endl; 986 999 mVspKdTree->Construct(rays, sceneBbox); 1000 1001 Debug << mVspKdTree->GetStatistics() << endl; 1002 987 1003 return 0; 988 1004 } … … 1022 1038 return; 1023 1039 1040 //-- export tree leaves 1024 1041 if (1) 1025 1042 { … … 1033 1050 exporter->ExportGeometry(objects); 1034 1051 1035 bool exportRays = true;1052 bool exportRays = false; 1036 1053 1037 1054 if (exportRays) … … 1086 1103 1087 1104 for (it = vssRays.begin(); it != it_end; ++ it) 1088 { 1089 //if (!(*it)->mOriginObject && !(*it)->mTerminationObject) 1090 rays.push_back(*it); 1091 1092 //if (!(*it)->mOriginObject && !(*it)->mTerminationObject) 1093 // Debug << "ERR: " << (*it)->mOrigin << " " << (*it)->mTermination << endl; 1094 } 1095 1105 rays.push_back(*it); 1106 1096 1107 exporter->ExportRays(rays, RgbColor(1, 0, 0)); 1097 1108 … … 1112 1123 } 1113 1124 1125 void VspKdViewCellsManager::PrintStatistics(ostream &s) const 1126 { 1127 } 1128 1114 1129 1115 1130 /**********************************************************************/ … … 1231 1246 int pvsSize = 0; 1232 1247 1248 1233 1249 BspViewCellsStatistics vcStats; 1234 1250 mVspBspTree->EvaluateViewCellsStats(vcStats); … … 1307 1323 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 1308 1324 1309 // statistics after post process1310 vcStats.Reset();1311 mVspBspTree->EvaluateViewCellsStats(vcStats);1312 Debug << "post processed view cell partition:\n" << vcStats << endl;1313 1325 1314 1326 return merged; … … 1429 1441 RayContainer vcRays; 1430 1442 cout << "creating output for view cell " << i << " ... "; 1443 1431 1444 // check whether we can add the current ray to the output rays 1432 /*for (int k = 0; k < raysOut; ++ k)1445 for (int k = 0; k < raysOut; ++ k) 1433 1446 { 1434 1447 Ray *ray = sampleRays[k]; … … 1444 1457 } 1445 1458 } 1446 */1459 1447 1460 1448 1461 Intersectable::NewMail(); … … 1613 1626 1614 1627 1628 void VspBspViewCellsManager::PrintStatistics(ostream &s) const 1629 { 1630 BspViewCellsStatistics vcStats; 1631 mVspBspTree->EvaluateViewCellsStats(vcStats); 1632 s << vcStats << endl; 1633 } 1634 1615 1635 bool VspBspViewCellsManager::MergeVspBspLeafViewCells(BspLeaf *front, 1616 1636 BspLeaf *back) const -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r448 r452 71 71 virtual int ComputeSampleContributions(Ray &ray, const bool castRay = true) = 0; 72 72 73 /** Prints out statistics of the view cells. 74 */ 75 virtual void PrintStatistics(ostream &s) const = 0; 76 73 77 /** Post processes view cells givemŽa number of rays. 74 78 */ … … 215 219 bool ViewCellsConstructed() const; 216 220 221 void PrintStatistics(ostream &s) const; 222 217 223 protected: 218 224 … … 269 275 270 276 277 /** Prints out statistics of this approach. 278 */ 279 virtual void PrintStatistics(ostream &s) const; 280 271 281 protected: 272 282 … … 309 319 bool ViewCellsConstructed() const; 310 320 321 virtual void PrintStatistics(ostream &s) const; 311 322 312 323 protected: … … 346 357 bool ViewCellsConstructed() const; 347 358 359 void PrintStatistics(ostream &s) const; 360 348 361 protected: 349 362 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r450 r452 946 946 947 947 // give penalty to unbalanced split 948 if ( 1)948 if (0) 949 949 if (((pFront * 0.2 + Limits::Small) > pBack) || 950 950 (pFront < (pBack * 0.2 + Limits::Small))) -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r449 r452 180 180 /**************************************************************/ 181 181 VspKdTreeLeaf::VspKdTreeLeaf(VspKdTreeInterior *p, const int nRays): 182 VspKdTreeNode(p), mRays(), mPvsSize(0), mValidPvs(false) 182 VspKdTreeNode(p), mRays(), mPvsSize(0), mValidPvs(false), mViewCell(NULL) 183 183 { 184 184 mRays.reserve(nRays); … … 447 447 VspKdTree::Construct(const VssRayContainer &rays, 448 448 AxisAlignedBox3 *forcedBoundingBox) 449 { Debug << "here888" << endl;449 { 450 450 mStat.Start(); 451 Debug << "here1000" << endl;451 452 452 mMaxMemory = mMaxStaticMemory; 453 Debug << "here1" << endl;454 453 DEL_PTR(mRoot); 455 454 … … 461 460 mStat.nodes = 1; 462 461 mBox.Initialize(); 463 Debug << "here2" << endl; 462 464 463 //-- compute bounding box 465 464 if (forcedBoundingBox) … … 468 467 for (VssRayContainer::const_iterator ri = rays.begin(); ri != rays.end(); ++ ri) 469 468 { 470 mBox.Include((*ri)->GetOrigin()); 471 mBox.Include((*ri)->GetTermination()); 469 if ((*ri)->mOriginObject) 470 mBox.Include((*ri)->GetOrigin()); 471 if ((*ri)->mTerminationObject) 472 mBox.Include((*ri)->GetTermination()); 472 473 } 473 474 … … 676 677 } 677 678 678 float ratio = 0;679 680 679 if (0) 681 680 { … … 702 701 const float oldCost = (float)pvsSize; 703 702 704 float ratio = newCost / oldCost; 705 } 706 707 return ratio; 703 return newCost / oldCost; 704 } 708 705 } 709 706 … … 731 728 if (!mOnlyDrivingAxis || axis == sAxis) 732 729 { 730 733 731 nPosition[axis] = (sBox.Min()[axis] + sBox.Max()[axis]) * 0.5f; 734 732 … … 740 738 nPvsBack[axis], 741 739 nPvsFront[axis]); 740 if (bestAxis == -1) 741 { 742 bestAxis = axis; 743 } 744 else if (nCostRatio[axis] < nCostRatio[bestAxis]) 745 { 746 /*Debug << "pvs front " << nPvsBack[axis] 747 << " pvs back " << nPvsFront[axis] 748 << " overall pvs " << leaf->GetPvsSize() << endl;*/ 749 bestAxis = axis; 750 } 742 751 743 if (bestAxis == -1)744 bestAxis = axis;745 else746 if (nCostRatio[axis] < nCostRatio[bestAxis])747 {748 Debug << "pvs front " << nPvsBack[axis]749 << " pvs back " << nPvsFront[axis]750 << " overall pvs " << leaf->GetPvsSize() << endl;751 bestAxis = axis;752 }753 752 } 754 753 } … … 1786 1785 } 1787 1786 } 1787 1788 int VspKdTree::FindNeighbors(VspKdTreeLeaf *n, 1789 vector<VspKdTreeLeaf *> &neighbors, 1790 bool onlyUnmailed) 1791 { 1792 stack<VspKdTreeNode *> nodeStack; 1793 1794 nodeStack.push(mRoot); 1795 1796 AxisAlignedBox3 box = GetBBox(n); 1797 1798 while (!nodeStack.empty()) 1799 { 1800 VspKdTreeNode *node = nodeStack.top(); 1801 nodeStack.pop(); 1802 1803 if (node->IsLeaf()) 1804 { 1805 VspKdTreeLeaf *leaf = dynamic_cast<VspKdTreeLeaf *>(node); 1806 1807 if (leaf != n && (!onlyUnmailed || !leaf->Mailed())) 1808 neighbors.push_back(leaf); 1809 } 1810 else 1811 { 1812 VspKdTreeInterior *interior = dynamic_cast<VspKdTreeInterior *>(node); 1813 1814 if (interior->mPosition > box.Max(interior->mAxis)) 1815 nodeStack.push(interior->mBack); 1816 else 1817 { 1818 if (interior->mPosition < box.Min(interior->mAxis)) 1819 nodeStack.push(interior->mFront); 1820 else 1821 { 1822 // random decision 1823 nodeStack.push(interior->mBack); 1824 nodeStack.push(interior->mFront); 1825 } 1826 } 1827 } 1828 } 1829 1830 return (int)neighbors.size(); 1831 } 1832 1833 void VspKdTree::MergeLeaves() 1834 { 1835 vector<VspKdTreeLeaf *> leaves; 1836 priority_queue<LeafPair> mergeCandidates; 1837 vector<VspKdTreeLeaf *> neighbors; 1838 1839 CollectLeaves(leaves); 1840 1841 VspKdTreeLeaf::NewMail(); 1842 1843 vector<VspKdTreeLeaf *>::const_iterator it, it_end = leaves.end(); 1844 1845 1846 for (it = leaves.begin(); it != it_end; ++ it) 1847 { 1848 VspKdTreeLeaf *leaf = *it; 1849 1850 if (!leaf->Mailed()) 1851 { 1852 FindNeighbors(leaf, neighbors, true); 1853 1854 vector<VspKdTreeLeaf *>::const_iterator nit, nit_end = neighbors.end(); 1855 1856 for (nit = neighbors.begin(); nit != neighbors.end(); ++ nit) 1857 mergeCandidates.push(LeafPair(leaf, *nit)); 1858 1859 leaf->Mail(); 1860 } 1861 } 1862 } 1863 1864 1865 1866 /*********************************************************************/ 1867 /* MergeCandidate implementation */ 1868 /*********************************************************************/ 1869 1870 1871 MergeCandidate::MergeCandidate(VspKdTreeLeaf *l1, VspKdTreeLeaf *l2): 1872 mLeaf1(l1), mLeaf2(l2) 1873 {} 1874 1875 int MergeCandidate::ComputePvsDifference() const 1876 { 1877 return 0; 1878 } 1879 1880 float MergeCandidate::EvaluateMergeCost() const 1881 { 1882 return 0; 1883 } -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h
r440 r452 33 33 #include "RayInfo.h" 34 34 #include "Containers.h" 35 36 class VspKdTreeLeaf; 37 38 /** 39 Candidate for leaf merging based on priority. 40 */ 41 class MergeCandidate 42 { 43 public: 44 VspKdTreeLeaf *mLeaf1; 45 VspKdTreeLeaf *mLeaf2; 46 47 MergeCandidate(VspKdTreeLeaf *l1, VspKdTreeLeaf *l2); 48 49 /** Computes PVS difference between the leaves. 50 */ 51 int ComputePvsDifference() const; 52 53 /** Evaluates the merge costs of this leaf. 54 */ 55 float EvaluateMergeCost() const; 56 57 friend bool operator<(const MergeCandidate &leafa, const MergeCandidate &leafb) 58 { 59 return leafa.ComputePvsDifference() < leafb.ComputePvsDifference(); 60 } 61 }; 62 63 35 64 36 65 /** … … 294 323 static int mailID; 295 324 296 297 325 protected: 298 326 … … 306 334 RayInfoContainer mRays; 307 335 bool mValidPvs; 308 336 337 ViewCell *mViewCell; 309 338 private: 310 339 int mPvsSize; … … 453 482 void CollectLeaves(vector<VspKdTreeLeaf *> &leaves) const; 454 483 484 /** Merges leaves of this tree according to some criteria. 485 */ 486 void MergeLeaves(); 487 488 /** Finds neighbours of this node. 489 @param n the input node 490 @param neighbours the neighbors of the input node 491 @param onlyUnmailed if only unmailed neighbors are collected 492 */ 493 int FindNeighbors(VspKdTreeLeaf *n, 494 vector<VspKdTreeLeaf *> &neighbors, 495 bool onlyUnmailed); 496 455 497 protected: 456 498 … … 547 589 548 590 protected: 591 592 549 593 ///////////////////////////// 550 594 // The core pointer … … 610 654 float mTermMaxRayContribution; 611 655 612 613 656 bool mOnlyDrivingAxis; 657 658 typedef std::pair<VspKdTreeLeaf *, VspKdTreeLeaf *> LeafPair; 659 614 660 ///////////////////////////// 615 661 VspKdStatistics mStat; -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r451 r452 10 10 #include "VssTree.h" 11 11 #include "ViewCellsManager.h" 12 #include "RenderSimulator.h" 12 13 13 14 bool useViewSpaceBox = true;//true; … … 440 441 cout << "#totalRayStackSize=" << mVssRays.size() << endl <<flush; 441 442 442 int numExportRays = 10000;443 //int numExportRays = 0;443 //int numExportRays = 10000; 444 int numExportRays = 0; 444 445 445 446 if (numExportRays) { … … 564 565 cout<<"*****************************\n"; 565 566 cout<<samples<<" avgPVS ="<<pvs<<endl; 567 cout<<"sample contributions ="<<sampleContributions<<endl; 568 cout<<"contributing sample ="<<contributingSamples<<endl; 566 569 cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 567 570 cout<<"*****************************\n"; … … 573 576 //-- post process view cells 574 577 mViewCellsManager->PostProcess(objects, storedRays); 578 579 //-- several visualizations and statistics 580 Debug << "===== Final view cells statistics ==========" << endl; 581 582 mViewCellsManager->PrintStatistics(Debug); 583 584 //-- render simulation after merge 585 cout << "\nevaluating bsp view cells render time after merge ... "; 586 587 const SimulationStatistics ss = mViewCellsManager->SimulateRendering(); 588 589 cout << " finished" << endl; 590 cout << ss << endl; 591 Debug << ss << endl; 592 575 593 mViewCellsManager->Visualize(objects, storedRays); 576 594 577 595 CLEAR_CONTAINER(storedRays); 578 596 579 597 delete vssTree; 580 598
Note: See TracChangeset
for help on using the changeset viewer.