Changeset 464
- Timestamp:
- 12/14/05 15:25:44 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r463 r464 1553 1553 RegisterOption("RssTree.splitType", optString, "split=", "queries"); 1554 1554 RegisterOption("RssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false"); 1555 RegisterOption("RssTree.useRss", optBool, "rss=", "false");1556 1555 1557 1556 RegisterOption("RssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000"); … … 1574 1573 RegisterOption("RssTree.dirSplitDepth", optInt, "dirsplidepth=", "10"); 1575 1574 1576 1575 RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs", "false"); 1576 RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree", "false"); 1577 RegisterOption("RssPreprocessor.Export.rays", optBool, "rss_export_rays", "false"); 1578 RegisterOption("RssPreprocessor.Export.numRays", optInt, "rss_export_num_rays=", "5000"); 1579 RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells", "false"); 1580 RegisterOption("RssPreprocessor.updateSubdivision", optBool, "rss_update_subdivision", "false"); 1581 1582 1577 1583 /************************************************************************************/ 1578 1584 /* View space partition BSP tree related options */ -
trunk/VUT/GtpVisibilityPreprocessor/src/Makefile
r463 r464 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.0-rc1) on: út 13. XII 21:49:0820053 # Generated by qmake (2.00a) (Qt 4.1.0-rc1) on: st 14. XII 10:37:40 2005 4 4 # Project: preprocessor.pro 5 5 # Template: app -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r463 r464 16 16 static bool fromBoxVisibility = false; 17 17 18 static bool exportPvs = false;19 static bool exportRssTree = false;20 21 static int numExportRays = 5000;22 // static int numExportRays = 0;23 24 static bool useViewcells = false;25 18 26 19 RssPreprocessor::RssPreprocessor(): … … 35 28 environment->GetBoolValue("RssPreprocessor.useImportanceSampling", mUseImportanceSampling); 36 29 environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 37 30 31 environment->GetBoolValue("RssPreprocessor.Export.pvs", mExportPvs); 32 environment->GetBoolValue("RssPreprocessor.Export.rssTree", mExportRssTree); 33 environment->GetBoolValue("RssPreprocessor.Export.rays", mExportRays); 34 environment->GetIntValue("RssPreprocessor.Export.numRays", mExportNumRays); 35 environment->GetBoolValue("RssPreprocessor.useViewcells", mUseViewcells); 36 37 environment->GetBoolValue("RssPreprocessor.updateSubdivision", mUpdateSubdivision); 38 38 39 mStats.open("stats.log"); 39 40 } … … 130 131 pointA, 131 132 objectB, 132 objectA); 133 objectA, 134 mPass 135 ); 133 136 vssRays.push_back(vssRay); 134 137 hits ++; … … 139 142 pointB, 140 143 objectA, 141 objectB); 144 objectB, 145 mPass 146 ); 142 147 vssRays.push_back(vssRay); 143 148 hits ++; … … 385 390 RssPreprocessor::ComputeVisibility() 386 391 { 387 392 cout<<"Rss Preprocessor started\n"<<flush; 393 cout<<"Memory/ray "<<sizeof(VssRay)+sizeof(RssTreeNode::RayInfo)<<endl; 388 394 mSceneGraph->CollectObjects(&mObjects); 389 395 … … 487 493 488 494 489 if ( numExportRays) {495 if (mExportRays) { 490 496 char filename[64]; 491 497 sprintf(filename, "rss-rays-initial.x3d"); 492 ExportRays(filename, mVssRays, numExportRays);493 } 494 495 if ( useViewcells)498 ExportRays(filename, mVssRays, mExportNumRays); 499 } 500 501 if (mUseViewcells) 496 502 // construct view cells 497 503 mViewCellsManager->Construct(mObjects, mVssRays, mViewSpaceBox); 498 504 499 505 rssTree = new RssTree; 500 // viewcells = Construct(mVssRays);501 506 502 507 if (fromBoxVisibility) … … 507 512 cout<<"RssTree root PVS size = "<<rssTree->GetRootPvsSize()<<endl; 508 513 509 if ( exportRssTree) {514 if (mExportRssTree) { 510 515 ExportRssTree("rss-tree-100.x3d", rssTree, Vector3(1,0,0)); 511 516 ExportRssTree("rss-tree-001.x3d", rssTree, Vector3(0,0,1)); … … 515 520 } 516 521 517 if ( exportPvs) {522 if (mExportPvs) { 518 523 ExportPvs("rss-pvs-initial.x3d", rssTree); 519 524 } … … 522 527 // get viewcells as kd tree boxes 523 528 vector<AxisAlignedBox3> kdViewcells; 529 524 530 if (0) { 525 531 vector<KdLeaf *> leaves; … … 560 566 rssTree->AddRays(vssRays); 561 567 562 if ( 1) {568 if (mUpdateSubdivision) { 563 569 int subdivided = rssTree->UpdateSubdivision(); 564 570 cout<<"subdivided leafs = "<<subdivided<<endl; … … 567 573 } 568 574 569 if ( useViewcells) {575 if (mUseViewcells) { 570 576 float avgPvs = GetAvgPvsSize(rssTree, kdViewcells); 571 577 cout<<"Average PVS size = "<<avgPvs<<endl; 572 578 } 573 579 574 if ( numExportRays) {580 if (mExportRays) { 575 581 char filename[64]; 576 582 if (mUseImportanceSampling) … … 579 585 sprintf(filename, "rss-rays-%04d.x3d", pass); 580 586 581 ExportRays(filename, vssRays, numExportRays);587 ExportRays(filename, vssRays, mExportNumRays); 582 588 } 583 589 584 590 samples+=num; 585 591 586 if ( useViewcells) {592 if (mUseViewcells) { 587 593 588 594 //-- prepare traversal rays for view cell intersections … … 625 631 } 626 632 627 if ( exportPvs) {633 if (mExportPvs) { 628 634 char filename[64]; 629 635 sprintf(filename, "rss-pvs-%04d.x3d", pass); … … 638 644 } 639 645 640 if ( useViewcells) {646 if (mUseViewcells) { 641 647 642 648 //-- post process view cells -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h
r451 r464 21 21 bool mUseImportanceSampling; 22 22 23 bool mExportPvs; 24 bool mExportRssTree; 25 bool mExportRays; 26 int mExportNumRays; 27 28 bool mUseViewcells; 29 bool mUpdateSubdivision; 30 23 31 AxisAlignedBox3 *mViewSpaceBox; 24 32 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp
r463 r464 121 121 environment->GetBoolValue("RssTree.randomize", randomize); 122 122 environment->GetBoolValue("RssTree.splitUseOnlyDrivingAxis", mSplitUseOnlyDrivingAxis); 123 environment->GetBoolValue("RssTree.useRss", mUseRss);124 123 125 124 environment->GetBoolValue("RssTree.interleaveDirSplits", mInterleaveDirSplits); … … 292 291 dirBBox.Initialize(); 293 292 294 if (mUseRss)295 forcedBoundingBox = NULL;296 293 297 294 mForcedBoundingBox = forcedBoundingBox; … … 990 987 // (leaf->GetAvgRayContribution() > termMaxRayContribution ) || 991 988 (leaf->depth >= termMaxDepth) || 992 (SqrMagnitude(GetBBox(leaf).Size()) <= termMinSize) || 993 (mUseRss && leaf->mPassingRays == leaf->rays.size()) 989 (SqrMagnitude(GetBBox(leaf).Size()) <= termMinSize) 994 990 ); 995 991 } … … 1769 1765 1770 1766 void 1767 RssTree::PickEdgeRays(RssTreeLeaf *leaf, 1768 int &r1, 1769 int &r2 1770 ) 1771 { 1772 int nrays = leaf->rays.size(); 1773 1774 if (nrays == 2) { 1775 r1 = 0; 1776 r2 = 1; 1777 return; 1778 } 1779 1780 int tries = min(20, nrays); 1781 1782 while (--tries) { 1783 r1 = Random(nrays); 1784 r2 = Random(nrays); 1785 if (leaf->rays[r1].mRay->mTerminationObject != leaf->rays[r2].mRay->mTerminationObject) 1786 break; 1787 } 1788 1789 if (r1 == r2) 1790 r2 = (r1+1)%leaf->rays.size(); 1791 } 1792 1793 1794 void 1771 1795 RssTree::GenerateLeafRays(RssTreeLeaf *leaf, 1772 1796 const int numberOfRays, … … 1776 1800 int nrays = leaf->rays.size(); 1777 1801 for (int i=0; i < numberOfRays; i++) { 1778 bool useExtendedConvexCombination = (nrays >= 3) && (i > numberOfRays/2);1802 bool useExtendedConvexCombination = (nrays >= 2) && (i > numberOfRays/2); 1779 1803 1780 1804 … … 1783 1807 if (useExtendedConvexCombination) { 1784 1808 // pickup 3 random rays 1785 int r1 = Random(nrays); 1786 int r2 = Random(nrays); 1787 int r3 = Random(nrays); 1809 int r1, r2; 1810 PickEdgeRays(leaf, r1, r2); 1788 1811 1789 1812 Vector3 o1 = leaf->rays[r1].GetOrigin(); 1790 1791 1813 Vector3 o2 = leaf->rays[r2].GetOrigin(); 1792 1814 1793 Vector3 o3 = leaf->rays[r3].GetOrigin(); 1794 1795 const float overlap = 0.0; 1796 1797 1798 float w1, w2, w3; 1799 GenerateExtendedConvexCombinationWeights(w1, w2, w3, overlap); 1800 origin = w1*o1 + w2*o2 + w3*o3; 1815 const float overlap = 0.1f; 1816 float w1, w2; 1817 GenerateExtendedConvexCombinationWeights2(w1, w2, overlap); 1818 origin = w1*o1 + w2*o2; 1801 1819 direction = 1802 1820 w1*leaf->rays[r1].mRay->GetDir() + 1803 w2*leaf->rays[r2].mRay->GetDir() + 1804 w3*leaf->rays[r3].mRay->GetDir(); 1821 w2*leaf->rays[r2].mRay->GetDir(); 1805 1822 // shift the origin a little bit 1806 1823 origin += direction*0.1f; -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.h
r463 r464 553 553 bool mSplitUseOnlyDrivingAxis; 554 554 555 // use ray space subdivision instead of view space subdivision556 bool mUseRss;557 555 558 556 // interleave directional and spatial splits based on their costs … … 853 851 854 852 853 void 854 PickEdgeRays(RssTreeLeaf *leaf, 855 int &r1, 856 int &r2 857 ); 858 855 859 }; 856 860 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.cpp
r459 r464 158 158 159 159 void 160 GenerateExtendedConvexCombinationWeights2(float &w1, 161 float &w2, 162 const float overlap 163 ) 164 { 165 w1 = RandomValue(-overlap, 1.0f + overlap); 166 w2 = 1.0f - w1; 167 } 168 169 void 160 170 GenerateExtendedConvexCombinationWeights(float &w1, 161 171 float &w2, … … 164 174 ) 165 175 { 166 w1 = RandomValue(-overlap, 1.0f + overlap); 167 w2 = RandomValue(-overlap, 1.0f + overlap); 168 w3 = 1.0f - w1 - w2; 176 177 while (1) { 178 w1 = RandomValue(-overlap, 1.0f + overlap); 179 w2 = RandomValue(-overlap, 1.0f + overlap); 180 w3 = 1.0f + overlap - w1 - w2; 181 if (w3 >= -overlap && w3 <= 1.0f + overlap) 182 break; 183 /* 184 w3 = RandomValue(0.0f, 1.0f + overlap); 185 186 float sum = w1 + w2 + w3; 187 if (sum>0.0f) { 188 w1/=sum; 189 w2/=sum; 190 w3/=sum; 191 break; 192 } 193 */ 194 } 169 195 } -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h
r463 r464 44 44 Intersectable *mOriginObject; 45 45 Intersectable *mTerminationObject; 46 46 47 //////////////////////// 48 // members related to importance sampling 49 // sampling pass in which this ray was generated 50 short mPass; 51 52 // number of cells where this ray made a contribution to the PVS 53 short mPvsContribution; 54 55 // sum of relative ray contributions per object 56 float mRelativePvsContribution; 57 47 58 ////////////////////////////// 48 VssRay(const Vector3 &origin, 59 VssRay( 60 const Vector3 &origin, 49 61 const Vector3 &termination, 50 62 Intersectable *originObject, 51 Intersectable *terminationObject): 63 Intersectable *terminationObject, 64 const int pass = 0 65 ): 52 66 mMailbox(-1), 53 67 mOrigin(origin), … … 56 70 mTerminationObject(terminationObject), 57 71 mRefCount(0), 58 mFlags(0) 72 mFlags(0), 73 mPass(pass) 59 74 // mT(1.0f) 60 75 { … … 66 81 mFlags(0), 67 82 mMailbox(-1), 68 mOriginObject(ray.sourceObject.mObject) 83 mOriginObject(ray.sourceObject.mObject), 84 mPass(0) 69 85 // mT(1.0f) 70 86 { … … 223 239 ); 224 240 241 void 242 GenerateExtendedConvexCombinationWeights2(float &w1, 243 float &w2, 244 const float overlap 245 ); 246 225 247 // -------------------------------------------------------------- 226 248 // For sorting rays -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r463 r464 65 65 samplesPerPass 100000 66 66 initialSamples 500000 67 vssSamples 5000000067 vssSamples 10000000 68 68 vssSamplesPerPass 500000 69 69 useImportanceSampling true 70 71 Export { 72 pvs false 73 rssTree false 74 rays true 75 numRays 5000 76 } 77 78 useViewcells false 79 updateSubdivision false 70 80 } 71 81 72 82 RssTree { 73 useRss false 83 74 84 epsilon 1e-6 75 85 -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r450 r464 26 26 27 27 char buff[128]; 28 29 28 environment->GetStringValue("Preprocessor.type", buff); 30 29 string preprocessorType(buff); … … 32 31 Preprocessor *p; 33 32 34 if (preprocessorType == "vss") 35 p = new VssPreprocessor(); 33 if (preprocessorType == "vss") 34 p = new VssPreprocessor(); 35 else 36 if (preprocessorType == "rss") 37 p = new RssPreprocessor(); 36 38 else 37 if (preprocessorType == " rss")38 p = new RssPreprocessor();39 if (preprocessorType == "exact") 40 p = new ExactPreprocessor(); 39 41 else 40 if (preprocessorType == "exact") 41 p = new ExactPreprocessor(); 42 else 43 if (preprocessorType == "sampling") 44 p = new SamplingPreprocessor(); 45 else { 46 cerr<<"Unknown preprocessor type"<<endl; 47 Debug<<"Unknown preprocessor type"<<endl; 48 exit(1); 49 } 50 51 42 if (preprocessorType == "sampling") 43 p = new SamplingPreprocessor(); 44 else { 45 cerr<<"Unknown preprocessor type"<<endl; 46 Debug<<"Unknown preprocessor type"<<endl; 47 exit(1); 48 } 49 50 52 51 environment->GetStringValue("Scene.filename", buff); 53 52 string filename(buff);
Note: See TracChangeset
for help on using the changeset viewer.