- Timestamp:
- 02/08/06 15:05:04 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r601 r605 13 13 #;../data/vienna/vienna-plane.x3d 14 14 # filename ../data/vienna/viewcells-25-sel.x3d 15 #filename ../data/atlanta/atlanta2.x3d15 filename ../data/atlanta/atlanta2.x3d 16 16 # filename ../data/soda/soda.dat 17 filename ../data/soda/soda5.dat17 # filename ../data/soda/soda5.dat 18 18 } 19 19 … … 25 25 type vss 26 26 # type rss 27 detectEmptyViewSpace true27 detectEmptyViewSpace false 28 28 } 29 29 … … 36 36 loadInitialSamples false 37 37 storeInitialSamples false 38 useViewSpaceBox true38 useViewSpaceBox false 39 39 # testBeamSampling true 40 40 } … … 176 176 # samples used for view cell construction 177 177 Construction { 178 samples 1400000178 samples 2500000 179 179 samplesPerPass 500000 180 180 } … … 213 213 useRaysForMerge false 214 214 refine false 215 compress true216 merge true215 compress false 216 merge false 217 217 } 218 218 … … 288 288 VspBspTree { 289 289 Construction { 290 samples 800000290 samples 500000 291 291 epsilon 0.005 292 292 randomize false … … 304 304 305 305 # maximal candidates for split planes 306 maxPolyCandidates 250306 maxPolyCandidates 0 307 307 308 308 … … 322 322 Termination { 323 323 # parameters used for autopartition 324 minRays 20324 minRays -1 325 325 minPolygons -1 326 326 maxDepth 40 327 327 minPvs -1 328 minProbability 0.000000 01329 maxRayContribution 0.15330 maxCostRatio 0.8331 missTolerance 3332 333 maxViewCells 100000328 minProbability 0.0000001 329 maxRayContribution 100000000.2 330 maxCostRatio 9.85 331 missTolerance 2 332 333 maxViewCells 2048 334 334 335 335 # used for pvs criterium … … 337 337 338 338 AxisAligned { 339 minRays 50000339 minRays 1 340 340 maxRayContribution 9.9 341 341 } 342 342 } 343 343 344 splitUseOnlyDrivingAxis false344 splitUseOnlyDrivingAxis true 345 345 346 346 Visualization { -
trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.cpp
r580 r605 100 100 const float pInVc = mViewCellsManager->GetProbability(vc); 101 101 102 //Debug << "vc prob: " << pInVc << endl; 103 102 104 // compute render time of PVS times probability 103 105 // that view point is in view cell … … 105 107 mViewCellsManager->GetRendercost(vc, mObjRenderCost); 106 108 109 renderTime += vcCost; 110 107 111 // crossing the border of a view cell is depending on the move 108 112 // speed and the probability that a view cell border is crossed 109 113 loadPvsOverhead += GetCrossVcProbability() * mVcOverhead; 110 renderTime += vcCost; 111 114 112 115 //-- update statistics 113 116 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r604 r605 160 160 161 161 162 void ViewCell::UpdateViewCellsStats(ViewCellsStatistics &vcStat)163 {164 ++ vcStat.viewCells;165 166 const int pvsSize = mPvs.GetSize();167 168 vcStat.pvs += pvsSize;169 170 if (pvsSize == 0)171 ++ vcStat.emptyPvs;172 173 if (pvsSize > vcStat.maxPvs)174 vcStat.maxPvs = pvsSize;175 176 if (pvsSize < vcStat.minPvs)177 vcStat.minPvs = pvsSize;178 179 if (!mValid)180 ++ vcStat.invalid;181 }182 183 184 162 float ViewCell::GetArea() const 185 163 { … … 477 455 mViewCellsManager->GetPvsStatistics(pvsStats); 478 456 479 static float expectedValue = pvsStats.avgPvs;457 //static float expectedValue = pvsStats.avgPvs; 480 458 481 459 // the current view cells are kept in this container … … 521 499 522 500 mStats << "#Pass\n" << pass << endl 523 << "#Merged\n" << mergeStats.merged << endl 524 << "#Viewcells\n" << realNumActiveViewCells << endl 525 << "#RenderCostIncrease\n" << 0 << endl 526 << "#TotalRenderCost\n" << totalRenderCost << endl 527 << "#CurrentPvs\n" << 0 << endl 528 << "#ExpectedCost\n" << realExpectedCost << endl 529 << "#AvgRenderCost\n" << realAvgRenderCost << endl 530 << "#Deviation\n" << mDeviation << endl 531 << "#TotalPvs\n" << totalPvs << endl 532 << "#PvsSizeDecrease\n" << 0 << endl 533 << "#Volume\n" << 0 << endl 534 << "#Dummy\n" << 0 << endl; 501 << "#Merged\n" << mergeStats.merged << endl 502 << "#Viewcells\n" << realNumActiveViewCells << endl 503 << "#RenderCostIncrease\n" << 0 << endl 504 << "#TotalRenderCost\n" << totalRenderCost << endl 505 << "#CurrentPvs\n" << 0 << endl 506 << "#ExpectedCost\n" << realExpectedCost << endl 507 << "#AvgRenderCost\n" << realAvgRenderCost << endl 508 << "#Deviation\n" << mDeviation << endl 509 << "#TotalPvs\n" << totalPvs << endl 510 << "#PvsSizeDecrease\n" << 0 << endl 511 << "#Volume\n" << endl; 535 512 536 513 //-- use priority queue to merge leaf pairs … … 584 561 } 585 562 586 #ifdef _DEBUG587 Debug << "abs mergecost: " << mMergeQueue.top().GetMergeCost() <<588 << " rel mergecost: " << mMergeQueue.top().GetRenderCost() / mExpectedCost <<589 << " max ratio: " << mMergeMaxCostRatio << endl590 << " expected value: " << realExpectedCost << endl;591 #endif592 563 593 564 … … 637 608 ++ mergeStats.siblings; 638 609 #endif 639 //if (((mergeStats.merged % statsOut) == 0) ||640 //(realNumActiveViewCells == mMergeMinViewCells))641 //{610 if (((mergeStats.merged % statsOut) == 0) || 611 (realNumActiveViewCells == mMergeMinViewCells)) 612 { 642 613 cout << "merged " << mergeStats.merged << " view cells" << endl; 643 614 … … 646 617 << "#Merged\n" << mergeStats.merged << endl 647 618 << "#Viewcells\n" << realNumActiveViewCells << endl 648 619 << "#RenderCostIncrease\n" << renderCostIncr << endl 649 620 << "#TotalRenderCost\n" << totalRenderCost << endl 650 621 << "#CurrentPvs\n" << mergedVc->GetPvs().GetSize() << endl 651 << "#ExpectedCost\n" << realExpectedCost / (float) realNumActiveViewCells<< endl622 << "#ExpectedCost\n" << realExpectedCost << endl 652 623 << "#AvgRenderCost\n" << realAvgRenderCost << endl 653 624 << "#Deviation\n" << mDeviation << endl 654 625 << "#TotalPvs\n" << totalPvs << endl 655 626 << "#PvsSizeDecrease\n" << -pvsDiff << endl 656 << "#Volume\n" << mergedVc->GetVolume() << endl 657 << "#Dummy\n" << (float)mergedVc->GetPvs().GetSize() * mergedVc->GetVolume() / mViewCellsManager->GetViewSpaceBox().GetVolume() << endl; 658 // } 627 << "#Volume\n" << mergedVc->GetVolume() << endl; 628 } 659 629 } 660 630 else … … 1489 1459 tstack.push(vc); 1490 1460 1491 Debug << "current size: " << pvsSize << endl;1492 1493 1461 while (!tstack.empty()) 1494 1462 { … … 1563 1531 return vc; 1564 1532 } 1533 1534 1535 1536 void ViewCellsTree::UpdateViewCellsStats(ViewCell *vc, ViewCellsStatistics &vcStat) 1537 { 1538 ++ vcStat.viewCells; 1539 1540 const int pvsSize = GetPvsSize(vc); 1541 1542 vcStat.pvs += pvsSize; 1543 1544 if (pvsSize == 0) 1545 ++ vcStat.emptyPvs; 1546 1547 if (pvsSize > vcStat.maxPvs) 1548 vcStat.maxPvs = pvsSize; 1549 1550 if (pvsSize < vcStat.minPvs) 1551 vcStat.minPvs = pvsSize; 1552 1553 if (!vc->GetValid()) 1554 ++ vcStat.invalid; 1555 } 1556 1565 1557 1566 1558 … … 1643 1635 1644 1636 1637 1645 1638 /************************************************************************/ 1646 1639 /* MergeStatistics implementation */ -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r604 r605 129 129 void SetArea(float area); 130 130 131 /** Updates the view cell statstics for this particular view cell.132 */133 virtual void UpdateViewCellsStats(ViewCellsStatistics &vcStat);134 131 135 132 /** if this view cell is the root of a view cell hierarchy … … 238 235 ViewCell(mesh), mLeaf(NULL) {} 239 236 240 void UpdateViewCellsStats(ViewCellsStatistics &vcStat) 241 { 242 ViewCell::UpdateViewCellsStats(vcStat); 243 // TODO 244 //if ((int)mLeaves.size() > vcStat.maxLeaves) 245 // vcStat.maxLeaves = (int)mLeaves.size(); 246 //vcStat.leaves += (int)mLeaves.size(); 247 } 237 248 238 249 239 bool IsLeaf() const … … 289 279 int RefineViewCells(const VssRayContainer &rays, const ObjectContainer &objects); 290 280 281 /** Updates view cell stats for this particular view cell 282 */ 283 void UpdateViewCellsStats(ViewCell *vc, ViewCellsStatistics &vcStat); 291 284 292 285 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r600 r605 1628 1628 { 1629 1629 pFront = frontCell.GetVolume(); 1630 pBack = backCell.GetVolume();1630 pBack = pOverall - pFront; 1631 1631 } 1632 1632 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r601 r605 16 16 #include "RssPreprocessor.h" 17 17 18 #define SAMPLE_AFTER_SUBDIVISION 1 18 19 19 20 … … 189 190 190 191 // TODO: leak? 191 if(0)ComputeSampleContributions(constructionSamples, true, false); 192 if (SAMPLE_AFTER_SUBDIVISION) 193 ComputeSampleContributions(constructionSamples, true, false); 192 194 cout << "finished" << endl; 193 195 … … 211 213 // store viewCells for postprocessing 212 214 const bool storeViewCells = true; 213 if(0)ComputeSampleContributions(postProcessSamples, true, storeViewCells); 215 216 if (SAMPLE_AFTER_SUBDIVISION) 217 ComputeSampleContributions(postProcessSamples, true, storeViewCells); 214 218 // merge the view cells 215 219 PostProcess(preprocessor->mObjects, postProcessSamples); … … 224 228 visualizationSamples); 225 229 226 if(0)ComputeSampleContributions(visualizationSamples, true, storeViewCells); 230 if (SAMPLE_AFTER_SUBDIVISION) 231 ComputeSampleContributions(visualizationSamples, true, storeViewCells); 227 232 228 233 //Debug << "visualizationsamples: " << mVisualizationSamples << " " << visualizationSamples.size() << endl; … … 377 382 for (it = mViewCells.begin(); it != it_end; ++ it) 378 383 { 379 (*it)->UpdateViewCellsStats(mViewCellsStats);384 mViewCellsTree->UpdateViewCellsStats(*it, mViewCellsStats); 380 385 } 381 386 } … … 858 863 859 864 865 float ViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 866 { 867 return mViewCellsTree->GetPvsSize(viewCell) * objRendercost; 868 } 869 870 860 871 float ViewCellsManager::GetAccVcArea() 861 872 { … … 1082 1093 1083 1094 1084 float BspViewCellsManager::GetRendercost(ViewCell *viewCell,1085 float objRendercost) const1086 {1087 return viewCell->GetPvs().GetSize() * objRendercost;1088 }1089 1090 1095 1091 1096 int BspViewCellsManager::CastLineSegment(const Vector3 &origin, … … 1157 1162 // reset view cells and stats 1158 1163 ResetViewCells(); 1164 Debug << "\nView cells after merge:\n" << mViewCellsStats << endl; 1159 1165 1160 1166 int savedColorCode = mColorCode; 1161 1167 1162 1168 //BspLeaf::NewMail(); 1163 1169 if (1) // export merged view cells 1164 1170 { 1165 1171 mColorCode = 0; 1166 cout << "reseting view cells ... "; 1167 ResetViewCells(); 1168 cout << "finished" << endl; 1169 1172 1170 1173 Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 1171 Debug << "\nView cells after merge:\n" << mViewCellsStats << endl;1174 1172 1175 1173 1176 cout << "exporting view cells after merge ... "; … … 1387 1390 ExportViewCellGeometry(exporter, vc); 1388 1391 1389 1390 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc)1391 << ", piercing rays=" << (int)vcRays.size() << endl;1392 // << ", leaves=" << (int)vc->mLeaves.size() << endl;1393 1394 1395 1392 // export rays piercing this view cell 1396 1393 exporter->ExportRays(vcRays, RgbColor(0, 1, 0)); … … 1677 1674 } 1678 1675 1676 1679 1677 float KdViewCellsManager::GetProbability(ViewCell *viewCell) 1680 1678 { 1681 1679 // compute view cell area / volume as subsititute for probability 1682 #if 0 1683 return GetArea(viewCell) / GetViewSpaceBox().SurfaceArea(); 1684 #endif 1685 #if 1 1686 return GetArea(viewCell) / GetAccVcArea(); 1687 #endif 1688 #if 0 1689 return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 1690 #endif 1691 } 1692 1693 1694 float KdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 1695 { 1696 return viewCell->GetPvs().GetSize() * objRendercost; 1697 } 1680 if (0) 1681 return GetArea(viewCell) / GetViewSpaceBox().SurfaceArea(); 1682 else 1683 return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 1684 } 1685 1686 1698 1687 1699 1688 … … 1810 1799 AxisAlignedBox3 box = mKdTree->GetBox(leaf); 1811 1800 exporter->ExportBox(box); 1812 1813 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize()1814 << ", piercing rays=" << (int)vcRays.size() << endl;1815 1801 1816 1802 // export rays piercing this view cell … … 1995 1981 float VspKdViewCellsManager::GetProbability(ViewCell *viewCell) 1996 1982 { 1997 // volume or area substitutes for view point probability 1998 #if 0 1999 return GetArea(viewCell) / GetViewSpaceBox().SurfaceArea(); 2000 #else 2001 return GetArea(viewCell) / GetAccVcArea(); 2002 #endif 2003 } 2004 2005 2006 float VspKdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 2007 { 2008 return viewCell->GetPvs().GetSize() * objRendercost; 2009 } 1983 // compute view cell area / volume as subsititute for probability 1984 if (0) 1985 return GetArea(viewCell) / GetViewSpaceBox().SurfaceArea(); 1986 else 1987 return GetVolume(viewCell) / GetViewSpaceBox().GetVolume(); 1988 } 1989 1990 2010 1991 2011 1992 … … 2144 2125 VspKdViewCell *vc = dynamic_cast<VspKdViewCell *>(mViewCells[idx]); 2145 2126 2146 cout << "Output view cell " << i << " with pvs size " << vc->GetPvs().GetSize() << endl;2147 Debug << "Output view cell " << i << " with pvs size " << vc->GetPvs().GetSize() << endl;2148 2127 //-- export geometry 2149 2128 Material m; … … 2393 2372 2394 2373 2395 float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell,2396 float objRendercost) const2397 {2398 return viewCell->GetPvs().GetSize() * objRendercost;2399 }2400 2401 2374 2402 2375 bool VspBspViewCellsManager::ViewCellsConstructed() const … … 2515 2488 2516 2489 cout << "Computing remaining ray contributions ... "; 2490 2517 2491 // recast rest of rays 2518 if ( 0)2519 ComputeSampleContributions(savedRays, true, false);2492 if (SAMPLE_AFTER_SUBDIVISION) 2493 ComputeSampleContributions(savedRays, true, false); 2520 2494 cout << "finished" << endl; 2521 2495 … … 2697 2671 2698 2672 VssRayContainer postProcessRays; 2699 if(0)GetRaySets(rays, mPostProcessSamples, postProcessRays); 2673 2674 GetRaySets(rays, mPostProcessSamples, postProcessRays); 2700 2675 2701 2676 Debug << "post processing using " << (int)postProcessRays.size() << " samples" << endl; … … 2718 2693 RefineViewCells(postProcessRays, objects); 2719 2694 2720 2721 if (1)2722 {2723 float totalCost, erc, var, dev, avg;2724 int totalpvs;2725 2726 mViewCellsStats.Reset();2727 2728 EvaluateRenderStatistics(totalCost, erc, dev, var, totalpvs, avg);2729 2730 Debug << "statistics after merge "2731 << " erc: " << erc2732 << " dev: " << dev2733 << " totalpvs: " << totalpvs2734 << " avg: " << avg << endl;2735 }2736 2737 2695 //-- render simulation after merge 2738 2739 2740 2741 2696 cout << "\nevaluating bsp view cells render time before compress ... "; 2697 dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 2698 SimulationStatistics ss; 2699 dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 2742 2700 2743 cout << " finished" << endl; 2744 cout << ss << endl; 2745 Debug << ss << endl; 2701 2702 cout << " finished" << endl; 2703 cout << ss << endl; 2704 Debug << ss << endl; 2746 2705 2747 2706 … … 2758 2717 pvsEntries = mViewCellsTree->GetNumPvsEntries(mViewCellsTree->GetRoot()); 2759 2718 Debug << "number of entries after compress: " << pvsEntries << endl; 2760 }2761 2762 2763 //-- export refined (shuffled) view cells2764 if (0)2765 {2766 cout << "exporting shuffled view cells ... ";2767 2768 Exporter *exporter = Exporter::GetExporter("shuffled_view_cells.x3d");2769 if (exporter)2770 {2771 if (1)2772 {2773 exporter->SetWireframe();2774 exporter->ExportBox(mViewSpaceBox);2775 exporter->SetFilled();2776 }2777 2778 if (mExportGeometry)2779 {2780 exporter->ExportGeometry(objects);2781 }2782 2783 ViewCellContainer::const_iterator vit, vit_end = mViewCells.end();2784 2785 Material vm, lm;2786 2787 for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit)2788 {2789 ViewCell *vc = *vit;2790 2791 vm = RandomMaterial();2792 2793 lm = vm;2794 2795 vm.mDiffuseColor.r -= 0.45f;2796 vm.mDiffuseColor.g -= 0.45f;2797 vm.mDiffuseColor.b -= 0.45f;2798 2799 2800 ViewCellContainer leaves;2801 mViewCellsTree->CollectLeaves(vc, leaves);2802 2803 ViewCellContainer::const_iterator lit, lit_end = leaves.end();2804 2805 for (lit = leaves.begin(); lit != lit_end; ++ lit)2806 {2807 BspLeaf *leaf = dynamic_cast<BspViewCell *>(*lit)->mLeaf;2808 2809 if (leaf->Mailed())2810 exporter->SetForcedMaterial(lm);2811 else2812 exporter->SetForcedMaterial(vm);2813 2814 BspNodeGeometry geom;2815 mVspBspTree->ConstructGeometry(leaf, geom);2816 exporter->ExportPolygons(geom.mPolys);2817 }2818 }2819 2820 delete exporter;2821 }2822 2823 2824 cout << "finished" << endl;2825 2719 } 2826 2720 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r600 r605 213 213 /** Returns render cost of a single view cell given the render cost of an object. 214 214 */ 215 virtual float GetRendercost(ViewCell *viewCell, float objRendercost) const = 0;215 virtual float GetRendercost(ViewCell *viewCell, float objRendercost) const ; 216 216 217 217 /** Returns container of loaded / generated view cells. … … 521 521 522 522 float GetProbability(ViewCell *viewCell); 523 float GetRendercost(ViewCell *viewCell, float objRendercost) const;523 524 524 525 525 /** Get a viewcell containing the specified point */ … … 603 603 604 604 float GetProbability(ViewCell *viewCell); 605 float GetRendercost(ViewCell *viewCell, float objRendercost) const; 605 606 606 607 607 void CreateMesh(ViewCell *vc); … … 669 669 670 670 float GetProbability(ViewCell *viewCell); 671 float GetRendercost(ViewCell *viewCell, float objRendercost) const;671 672 672 673 673 void CreateMesh(ViewCell *vc); … … 728 728 729 729 float GetProbability(ViewCell *viewCell); 730 float GetRendercost(ViewCell *viewCell, float objRendercost) const;730 731 731 732 732 ViewCell *GetViewCell(const Vector3 &point) const; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r604 r605 67 67 mOutOfBoundsCell(NULL), 68 68 mStoreRays(false), 69 mRenderCostWeight(0.5) 69 mRenderCostWeight(0.5), 70 mUseRandomAxis(false) 70 71 { 71 72 bool randomize = false; … … 429 430 tQueue.push(tData); 430 431 431 mTotalCost = tData. GetCost()/ mBox.GetVolume();432 mTotalCost = tData.mPvs * tData.mProbability / mBox.GetVolume(); 432 433 433 434 mSubdivisionStats 434 << "# Leaves\n1\n" << endl435 << "#ViewCells\n1\n" << endl 435 436 << "#RenderCostDecrease\n0\n" << endl 436 437 << "#TotalRenderCost\n" << mTotalCost << endl; … … 528 529 if (1) 529 530 { 531 float cFront = tFrontData.mPvs * tFrontData.mProbability; 532 float cBack = tBackData.mPvs * tBackData.mProbability; 533 float cData = tData.mPvs * tData.mProbability;; 534 530 535 float costDecr = 531 ( tFrontData.GetCost() + tBackData.GetCost() - tData.GetCost()) / mBox.GetVolume();536 (cFront + cBack - cData) / mBox.GetVolume(); 532 537 mTotalCost += costDecr; 533 538 534 539 mSubdivisionStats 535 << "# Leaves\n" << mBspStats.Leaves() << endl540 << "#ViewCells\n" << mBspStats.Leaves() << endl 536 541 << "#RenderCostDecrease\n" << -costDecr << endl 537 542 << "#TotalRenderCost\n" << mTotalCost << endl; … … 957 962 } 958 963 959 const int sAxis = box.Size().DrivingAxis();964 const int sAxis = mUseRandomAxis ? Random(3) : box.Size().DrivingAxis(); 960 965 961 966 for (axis = 0; axis < 3; ++ axis) -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r600 r605 710 710 ofstream mSubdivsionStats; 711 711 712 bool mUseRandomAxis; 712 713 private: 713 714 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r600 r605 791 791 //-- render simulation after merge 792 792 cout << "\nevaluating bsp view cells render time after sampling ... "; 793 Debug << "\nStatistics after sampling: " << endl; 794 793 795 mRenderSimulator->RenderScene(); 794 796 SimulationStatistics ss;
Note: See TracChangeset
for help on using the changeset viewer.