Changeset 1900 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 12/15/06 23:40:27 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp
r1894 r1900 29 29 30 30 31 // Environment::GetSingleton()->GetBoolValue("RssPreprocessor.Export.rays", mExportRays);32 // Environment::GetSingleton()->GetIntValue("RssPreprocessor.Export.numRays", mExportNumRays);33 31 } 34 32 … … 71 69 for (int i=0; i < mTotalSamples; i += mSamplesPerPass, mPass++) { 72 70 73 if (i - lastEvaluation >= mSamplesPerEvaluation) {74 mStats <<75 "#Pass\n" <<mPass<<endl<<76 "#Time\n" << TimeDiff(startTime, GetTime())<<endl<<77 "#TotalSamples\n" <<i<<endl<<78 "#RssSamples\n" <<totalVssRays<<endl;79 vssRays.PrintStatistics(mStats);80 mViewCellsManager->PrintPvsStatistics(mStats);81 lastEvaluation = i;82 }83 71 84 72 cout<<"Progress : "<<(100.0f*i)/mTotalSamples<<"%"<<endl; … … 90 78 CastRays(rays, vssRays, true, pruneInvalidRays); 91 79 totalVssRays += (int)vssRays.size(); 92 80 81 if (mExportRays) { 82 Debug<<"Exporting rays..."<<endl<<flush; 83 char filename[256]; 84 sprintf(filename, "rss-rays-i%04d.x3d", mPass); 85 ExportRays(filename, vssRays, mExportNumRays); 86 87 // VssRayContainer contributingRays; 88 // vssRays.GetContributingRays(contributingRays, 0); 89 // sprintf(filename, "rss-crays-%04d.x3d", mPass); 90 // ExportRays(filename, contributingRays, mExportNumRays); 91 Debug<<"done."<<endl<<flush; 92 } 93 93 94 mMixtureDistribution->ComputeContributions(vssRays); 94 95 96 if (i - lastEvaluation >= mSamplesPerEvaluation) { 97 mViewCellsManager->PrintPvsStatistics(mStats); 98 mStats << 99 "#Pass\n" <<mPass<<endl<< 100 "#Time\n" << TimeDiff(startTime, GetTime())<<endl<< 101 "#TotalSamples\n" <<i<<endl<< 102 "#RssSamples\n" <<totalVssRays<<endl; 103 lastEvaluation = i; 104 } 105 106 107 108 if (!mMixtureDistribution->RequiresRays()) 109 CLEAR_CONTAINER(vssRays); 95 110 } 111 96 112 return true; 97 98 113 } 99 114 -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1895 r1900 1840 1840 "preprocessor_use_viewspace_box=", 1841 1841 "false"); 1842 1843 RegisterOption("Preprocessor.Export.rays", optBool, "export_rays=", "false"); 1844 RegisterOption("Preprocessor.Export.numRays", optInt, "export_num_rays=", "5000"); 1842 1845 1843 1846 /*************************************************************************/ … … 1962 1965 RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs=", "false"); 1963 1966 RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree=", "false"); 1964 RegisterOption("RssPreprocessor.Export.rays", optBool, "rss_export_rays=", "false"); 1965 RegisterOption("RssPreprocessor.Export.numRays", optInt, "rss_export_num_rays=", "5000"); 1967 1966 1968 RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells=", "false"); 1967 1969 RegisterOption("RssPreprocessor.updateSubdivision", -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r1891 r1900 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: st 13. XII 23:09:0820063 # Generated by qmake (2.00a) (Qt 4.1.2) on: ?t 14. XII 10:54:14 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app … … 63 63 $(MAKE) -f $(MAKEFILE).Debug uninstall 64 64 65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc .net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 66 66 C:\Qt\4.1.2\mkspecs\features\qt_config.prf \ 67 67 C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \ -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1898 r1900 167 167 Environment::GetSingleton()->GetBoolValue("Preprocessor.useViewSpaceBox", mUseViewSpaceBox); 168 168 169 Environment::GetSingleton()->GetBoolValue("Preprocessor.Export.rays", mExportRays); 170 Environment::GetSingleton()->GetIntValue("Preprocessor.Export.numRays", mExportNumRays); 171 169 172 Debug << "******* Preprocessor Options **********" << endl; 170 173 Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; … … 1220 1223 } 1221 1224 1222 } 1225 1226 bool 1227 Preprocessor::ExportRays(const char *filename, 1228 const VssRayContainer &vssRays, 1229 const int number 1230 ) 1231 { 1232 cout<<"Exporting vss rays..."<<endl<<flush; 1233 1234 Exporter *exporter = NULL; 1235 exporter = Exporter::GetExporter(filename); 1236 1237 if (0) { 1238 exporter->SetWireframe(); 1239 exporter->ExportKdTree(*mKdTree); 1240 } 1241 1242 exporter->SetFilled(); 1243 // $$JB temporarily do not export the scene 1244 if (0) 1245 exporter->ExportScene(mSceneGraph->GetRoot()); 1246 1247 exporter->SetWireframe(); 1248 1249 if (1) { 1250 exporter->SetForcedMaterial(RgbColor(1,0,1)); 1251 exporter->ExportBox(mViewCellsManager->GetViewSpaceBox()); 1252 exporter->ResetForcedMaterial(); 1253 } 1254 1255 VssRayContainer rays; 1256 vssRays.SelectRays(number, rays); 1257 exporter->ExportRays(rays, RgbColor(1, 0, 0)); 1258 delete exporter; 1259 cout<<"done."<<endl<<flush; 1260 1261 return true; 1262 } 1263 1264 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1884 r1900 121 121 bool ExportKdTree(const string filename); 122 122 123 virtual bool 124 ExportRays(const char *filename, 125 const VssRayContainer &vssRays, 126 const int number 127 ); 128 123 129 virtual int 124 130 GenerateRays(const int number, … … 203 209 204 210 bool mExportObj; 211 212 bool mExportRays; 213 int mExportNumRays; 205 214 206 215 ofstream mStats; -
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
r1883 r1900 95 95 96 96 // regardless of the pruneInvalidRays setting reject rays whic degenerate to a point 97 if (EpsilonEqualV3(hitA.mPoint, hitB.mPoint, Limits::Small))98 return 0;97 // if (EpsilonEqualV3(hitA.mPoint, hitB.mPoint, Limits::Small)) 98 // return 0; 99 99 100 100 if (pruneInvalidRays) { -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1891 r1900 164 164 165 165 166 bool167 RssPreprocessor::ExportRays(const char *filename,168 const VssRayContainer &vssRays,169 const int number170 )171 {172 cout<<"Exporting vss rays..."<<endl<<flush;173 174 Exporter *exporter = NULL;175 exporter = Exporter::GetExporter(filename);176 if (0) {177 exporter->SetWireframe();178 exporter->ExportKdTree(*mKdTree);179 }180 exporter->SetFilled();181 // $$JB temporarily do not export the scene182 if (0)183 exporter->ExportScene(mSceneGraph->GetRoot());184 exporter->SetWireframe();185 186 if (1) {187 exporter->SetForcedMaterial(RgbColor(1,0,1));188 exporter->ExportBox(mViewCellsManager->GetViewSpaceBox());189 exporter->ResetForcedMaterial();190 }191 192 VssRayContainer rays;193 194 vssRays.SelectRays(number, rays);195 196 exporter->ExportRays(rays, RgbColor(1, 0, 0));197 198 delete exporter;199 200 cout<<"done."<<endl<<flush;201 202 return true;203 }204 166 205 167 bool -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.h
r1884 r1900 33 33 bool mExportPvs; 34 34 bool mExportRssTree; 35 bool mExportRays;36 int mExportNumRays;37 35 38 36 bool mUseViewcells; … … 72 70 73 71 74 bool75 ExportRays(const char *filename,76 const VssRayContainer &vssRays,77 const int number78 );79 72 80 73 bool -
GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
r1891 r1900 365 365 366 366 RssTreeNode::RayInfo info(*ri); 367 367 if (!EpsilonEqualV3(info.GetOrigin(), info.GetTermination(), Limits::Small)) { 368 368 369 // first construct a leaf that will get subdivide 369 370 RssTreeLeaf *leaf = (RssTreeLeaf *) GetRoot(info.GetSourceObject()); 371 370 372 371 373 leaf->AddRay(info); … … 389 391 leaf->dirBBox.Include(dVec); 390 392 dirBBox.Include(dVec); 393 } 391 394 } 392 395 … … 1456 1459 if (stat.rayRefs > mMaxRays) { 1457 1460 Debug<<"Prunning rays..."<<endl<<flush; 1458 PruneRays( mMaxRays);1461 PruneRays(0.8f*mMaxRays); 1459 1462 Debug<<"done."<<endl<<flush; 1460 1463 // UpdateTreeStatistics(); 1461 1464 } 1462 1463 1465 } 1464 1466 … … 1553 1555 RssTree::AddRay(RssTreeNode::RayInfo &info) 1554 1556 { 1557 if (EpsilonEqualV3(info.GetOrigin(), info.GetTermination(), Limits::Small)) 1558 return; 1555 1559 1556 1560 stack<RayTraversalData> tstack; … … 1561 1565 RayTraversalData data; 1562 1566 1567 1563 1568 while (!tstack.empty()) { 1564 1569 data = tstack.top(); … … 1807 1812 RssTree::UpdateTreeStatistics() 1808 1813 { 1814 for (int i=0; i < mRoots.size(); i++) 1815 UpdateImportance(mRoots[i]); 1816 1817 #if 0 1809 1818 stack<RssTreeNode *> tstack; 1810 1819 … … 1819 1828 int leaves = 0; 1820 1829 1821 for (int i=0; i < mRoots.size(); i++)1822 UpdateImportance(mRoots[i]);1823 1830 1824 1831 PushRoots(tstack); 1825 1832 1826 1833 while (!tstack.empty()) { 1827 1834 RssTreeNode *node = tstack.top(); … … 1871 1878 stat.avgWeightedRayContribution = sumWeightedRayContribution/(float)sumRays; 1872 1879 stat.rayRefs = (int)sumRays; 1880 #endif 1873 1881 1874 1882 } … … 2822 2830 float c1 = weight*ray->mPvsContribution; 2823 2831 float c2 = weight*ray->mRelativePvsContribution; 2832 2824 2833 sumContributions += c1; 2825 2834 if (c1 > maxContribution) … … 2832 2841 sumRelContributions += c2; 2833 2842 if (c2 > maxRelContribution) 2834 2835 2843 maxRelContribution = c2; 2844 2836 2845 //sumWeights += weight; 2837 2846 sumWeights += 1.0f; … … 2864 2873 leaf->mImportance = 2865 2874 pow(((weightAbsContributions*sumContributions + 2866 (1.0f - weightAbsContributions)*sumRelContributions)/sumWeights), 3);2867 #else 2875 (1.0f - weightAbsContributions)*sumRelContributions)/sumWeights), 1.0f); 2876 #else 1 2868 2877 leaf->mImportance = 2869 2878 (weightAbsContributions*maxContribution + -
GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.h
r1884 r1900 307 307 // 308 308 ///////////////////////////////// 309 309 310 310 311 311 // the bbox of the node … … 317 317 // evaluated importance of this node 318 318 float mImportance; 319 320 // importance requires update 321 //bool mRequiresUpdate; 319 322 320 323 inline RssTreeNode(RssTreeInterior *p); … … 1133 1136 1134 1137 virtual void Update(VssRayContainer &vssRays); 1138 virtual bool RequiresRays() { return true; } 1135 1139 1136 1140 private: -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
r1883 r1900 87 87 int intersectables, faces; 88 88 mSceneGraph->GetStatistics(intersectables, faces); 89 HaltonSequence halton; 89 90 90 91 int samples = 0; … … 99 100 cout<<"+"; 100 101 102 float r[5]; 103 halton.GetNext(5, r); 101 104 Vector3 origin, direction; 102 mViewCellsManager->GetViewPoint( origin);105 mViewCellsManager->GetViewPoint(origin, Vector3(r[0], r[1], r[2])); 103 106 104 direction = UniformRandomVector( );107 direction = UniformRandomVector(r[3],r[4]); 105 108 ViewCell *viewcell = mViewCellsManager->GetViewCell(origin); 106 109 -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r1899 r1900 495 495 float r; 496 496 sHalton.GetNext(1, &r); 497 497 int i; 498 498 // pickup a distribution 499 for (i nt i=0; i < mDistributions.size()-1; i++)499 for (i=0; i < mDistributions.size()-1; i++) 500 500 if (r < mDistributions[i]->mRatio) 501 501 break; … … 528 528 mDistributions[i]->mContribution += contribution; 529 529 mDistributions[i]->mRays ++; 530 530 531 531 mDistributions[i]->mTotalContribution += contribution; 532 532 mDistributions[i]->mTotalRays ++; … … 553 553 float importance = 0.0f; 554 554 if (mDistributions[i]->mRays != 0) { 555 importance = pow(mDistributions[i]->mContribution/mDistributions[i]->mRays, 3); 556 } 557 if (importance < Limits::Small) 558 importance = Limits::Small; 555 // importance = pow(mDistributions[i]->mContribution/mDistributions[i]->mRays, 3); 556 importance = mDistributions[i]->mContribution/mDistributions[i]->mRays; 557 } 559 558 mDistributions[i]->mRatio = importance; 560 559 sum += importance; 561 560 } 562 561 563 const float minratio = 0.0 5f;562 const float minratio = 0.02f; 564 563 float threshold = minratio*sum; 565 564 for (i=0; i < mDistributions.size(); i++) { -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
r1899 r1900 57 57 58 58 virtual bool GenerateSample(SimpleRay &ray) = 0; 59 59 60 // true if the strategy keeps pointers to rays and thus they should get deleted 61 // outside, in that case the strategy has to use reference counting and deleting the rays 62 // by itself if the number of references drops to zero 63 virtual bool RequiresRays() { return false; } 60 64 61 65 … … 70 74 public: 71 75 72 73 74 75 76 77 78 79 80 81 76 /// variables usefull for mixed distribution sampling 77 int mType; 78 int mRays; 79 float mContribution; 80 81 int mTotalRays; 82 float mTotalContribution; 83 84 float mTime; 85 float mRatio; 82 86 83 87 protected: … … 273 277 Construct(char *str); 274 278 279 virtual bool RequiresRays() { 280 for (int i=0; i < mDistributions.size(); i++) 281 if (mDistributions[i]->RequiresRays()) 282 return true; 283 return false; 284 } 285 275 286 private: 276 287 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1895 r1900 27 27 28 28 // $$JB HACK 29 #define USE_KD_PVS 029 #define USE_KD_PVS 1 30 30 31 31 #define KD_PVS_AREA (1e-5f) 32 33 #define USE_RAY_LENGTH_AS_CONTRIBUTION 0 34 #define DIST_WEIGHTED_CONTRIBUTION 1 32 35 33 36 namespace GtpVisibilityPreprocessor { … … 1536 1539 const bool storeViewCells) 1537 1540 { 1538 // view cells not yet constructed1539 if (!ViewCellsConstructed())1540 return 0.0f;1541 1542 1541 float sum = 0.0f; 1542 1543 1543 VssRayContainer::const_iterator it, it_end = rays.end(); 1544 1544 1545 1545 for (it = rays.begin(); it != it_end; ++ it) 1546 1546 { 1547 sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 1547 if (!ViewCellsConstructed()) { 1548 // view cells not yet constructed 1549 // just take the lenghts of the rays as contributions 1550 if ((*it)->mTerminationObject) 1551 sum += (*it)->Length(); 1552 } else { 1553 sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 1554 } 1548 1555 } 1549 1556 … … 2009 2016 float 2010 2017 ViewCellsManager::ComputeSampleContribution(VssRay &ray, 2011 2012 2018 const bool addRays, 2019 const bool storeViewCells) 2013 2020 { 2014 2021 ray.mPvsContribution = 0; … … 2059 2066 { 2060 2067 // todo: maybe not correct for kd node pvs 2061 if (viewcell->GetPvs().GetSampleContribution( 2062 terminationObj, ray.mPdf, contribution)) 2068 bool absContribution = viewcell->GetPvs().GetSampleContribution( 2069 terminationObj, 2070 ray.mPdf, 2071 contribution); 2072 #if DIST_WEIGHTED_CONTRIBUTION 2073 // clear the relative contribution 2074 contribution = 0.0f; 2075 #endif 2076 if (absContribution) 2063 2077 { 2064 2078 ++ ray.mPvsContribution; … … 2073 2087 #endif 2074 2088 } 2089 #if DIST_WEIGHTED_CONTRIBUTION 2090 // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the 2091 // object-> a new contribution in the proximity of the viewcell has a larger weight! 2092 contribution = 1.0f/SqrDistance(GetViewCellBox(viewcell).Center(), 2093 ray.mTermination); 2094 #endif 2075 2095 } 2076 2096 … … 2079 2099 } 2080 2100 } 2081 2101 2102 #if USE_RAY_LENGTH_AS_CONTRIBUTION 2103 float c = 0.0f; 2104 if (terminationObj) 2105 c = ray.Length(); 2106 ray.mRelativePvsContribution = ray.mPvsContribution = c; 2107 return c; 2108 #else 2082 2109 return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 2083 2110 (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 2111 #endif 2084 2112 } 2085 2113 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h
r1883 r1900 14 14 class KdNode; 15 15 16 #define ABS_CONTRIBUTION_WEIGHT 1.0f16 #define ABS_CONTRIBUTION_WEIGHT 0.0f 17 17 18 18 class VssRay { -
GTP/trunk/Lib/Vis/Preprocessing/src/default.env
r1891 r1900 73 73 file histogram.log 74 74 } 75 Export { 76 rays true 77 numRays 5000 78 } 79 75 80 } 76 81 … … 96 101 # distributions object_direction 97 102 98 samplesPerPass 200000103 samplesPerPass 1000000 99 104 initialSamples 2000000 100 vssSamples 50000000101 vssSamplesPerPass 500000 105 vssSamples 20000000 106 vssSamplesPerPass 5000000 102 107 useImportanceSampling true 103 108 104 directionalSampling false105 objectBasedSampling false106 109 107 110 Export { 108 111 pvs false 109 112 rssTree false 110 rays true111 numRays 5000112 113 } 113 114 … … 131 132 # splitType heuristic 132 133 133 minRays 100134 minRays 50 134 135 minSize 0.001 135 136 maxCostRatio 1.0 136 137 maxRayContribution 1.0 137 maxRays 10000000138 maxRays 2000000 138 139 maxTotalMemory 400 139 140 maxStaticMemory 200 -
GTP/trunk/Lib/Vis/Preprocessing/src/run_test2
r1883 r1900 2 2 3 3 #COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+" 4 COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter +"4 COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter-" 5 5 6 6 #SCENE="../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d" … … 35 35 36 36 37 # 38 # 39 # 37 #$COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 38 #-view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \ 39 #-preprocessor_histogram_file=$PREFIX-r-reference.hlog 40 40 41 41 42 #$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 43 #-rss_update_subdivision+ -rss_split=hybrid -hybrid_depth=10 \ 44 #-view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-i-combined-update-ccb12-nn.log \ 45 #-preprocessor_histogram_file=$PREFIX-i-combined-update-ccb12-nn.hlog 46 42 47 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 43 # -rss_update_subdivision+ -rss_split=hybrid -hybrid_depth=10 \ 44 # -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-i-combined-update-ccb12-nn.log \ 45 # -preprocessor_histogram_file=$PREFIX-i-combined-update-ccb12-nn.hlog 46 47 $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 48 -rss_update_subdivision- -rss_split=hybrid -hybrid_depth=10 \ 49 -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-i-combined-ccb12-nn.log \ 50 -preprocessor_histogram_file=$PREFIX-i-combined-ccb12-nn.hlog 48 # -rss_update_subdivision- -rss_split=hybrid -hybrid_depth=10 \ 49 # -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-i-combined-ccb12-nn.log \ 50 # -preprocessor_histogram_file=$PREFIX-i-combined-ccb12-nn22.hlog 51 51 52 52 … … 64 64 65 65 66 #$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \67 #-rss_distributions=spatial+object_direction -view_cells_filter_max_size=1 \68 # -preprocessor_stats=$PREFIX-i-mixed-b1-n.log \69 # -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n.hlog66 $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 67 -rss_distributions=object_direction+spatial+object+direction -view_cells_filter_max_size=1 \ 68 -preprocessor_stats=$PREFIX-i-mixed-b1-n225678.log \ 69 -preprocessor_histogram_file=$PREFIX-i-mixed-b1-n225678.hlog 70 70 71 71
Note: See TracChangeset
for help on using the changeset viewer.