Changeset 1919
- Timestamp:
- 12/21/06 23:52:10 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1912 r1919 1314 1314 "5000"); 1315 1315 1316 RegisterOption("ViewCells.Evaluation.histoMem", 1317 optInt, 1318 "view_cells_evaluation_histo_mem=", 1319 "50"); 1320 1316 1321 RegisterOption("ViewCells.renderCostEvaluationType", 1317 1322 optString, -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1917 r1919 2058 2058 int &viewSpaceSplits, 2059 2059 int &objectSpaceSplits, 2060 const bool useFilter) 2060 const bool useFilter, 2061 const bool useHisto, 2062 const int histoMem, 2063 const int pass, 2064 bool &histoUsed) 2061 2065 { 2062 2066 ViewCellContainer viewCells; … … 2121 2125 { 2122 2126 ComputePvs(vc->GetPvs(), rc, pvsEntries); 2127 vc->SetPvsCost(rc); 2123 2128 } 2124 2129 … … 2132 2137 viewSpaceSplits = (int)viewCells.size(); 2133 2138 objectSpaceSplits = (int)bvhNodes.size(); 2139 2140 //////////////////////// 2141 //-- evaluate histogram for pvs size 2142 2143 if (useHisto && (memory <= (float)histoMem)) 2144 { 2145 char str[100]; 2146 char statsPrefix[100]; 2147 int histoStepSize; 2148 2149 Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); 2150 2151 cout << "computing pvs histogram for " << histoMem << " memory" << endl; 2152 Debug << "computing pvs histogram for " << histoMem << " memory" << endl; 2153 2154 sprintf(str, "-%05d-%05d-histo-pvs.log", pass, histoMem); 2155 const string filename = string(statsPrefix) + string(str); 2156 2157 mVspTree->mViewCellsManager->EvalViewCellHistogramForPvsSize(filename, viewCells); 2158 2159 histoUsed = true; 2160 } 2161 2134 2162 //cout << "viewCells: " << (int)viewCells.size() << " nodes: " << (int)bvhNodes.size() << " rc: " << renderCost << " entries: " << pvsEntries << endl; 2135 2163 … … 2325 2353 void HierarchyManager::EvaluateSubdivision2(ofstream &splitsStats, 2326 2354 const int splitsStepSize, 2327 const bool useFilter) 2355 const bool useFilter, 2356 const bool useHisto, 2357 const int histoMem, 2358 const int pass) 2328 2359 { 2329 2360 vector<HierarchySubdivisionStats> subStatsContainer; … … 2331 2362 int splits = (1 + (mHierarchyStats.Leaves() - 1) / splitsStepSize) * splitsStepSize; 2332 2363 cout << "splits: " << splits << endl; 2364 2365 bool histoUsed = false; 2333 2366 2334 2367 while (1) … … 2342 2375 subStats.mViewSpaceSplits, 2343 2376 subStats.mObjectSpaceSplits, 2344 useFilter); 2377 useFilter, 2378 useHisto && !histoUsed, 2379 histoMem, 2380 pass, 2381 histoUsed); 2345 2382 2346 2383 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1912 r1919 288 288 void EvaluateSubdivision2(ofstream &splitsStats, 289 289 const int splitsStepSize, 290 const bool useFilter); 290 const bool useFilter, 291 const bool useHisto, 292 const int histoMem, 293 const int pass); 291 294 292 295 … … 526 529 int &viewSpaceSplits, 527 530 int &objectSpaceSplits, 528 const bool useFilter); 531 const bool useFilter, 532 const bool useHisto, 533 const int histoMem, 534 const int pass, 535 bool &histoUsed); 529 536 530 537 void ComputePvs(const ObjectPvs &pvs, float &rc, int &pvsEntries); -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj
r1918 r1919 92 92 Name="VCLinkerTool" 93 93 AdditionalDependencies="xerces-c_2.lib glew32.lib zdll.lib zziplib.lib devil.lib glut32.lib OpenGL32.Lib glu32.lib Preprocessor.lib" 94 OutputFile="$(OutDir)/Preprocessor 2.exe"94 OutputFile="$(OutDir)/Preprocessor.exe" 95 95 LinkIncremental="1" 96 96 AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib" -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1918 r1919 147 147 148 148 // mix of sampling strategies 149 mStrategies.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION); 150 151 /*mStrategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 152 mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 153 mStrategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 154 */ 155 //mStrategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 149 if (0) 150 { 151 mStrategies.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION); 152 } 153 else 154 { 155 /*mStrategies.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 156 mStrategies.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 157 mStrategies.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 158 */ 159 160 mStrategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 161 } 156 162 157 163 Debug << "casting strategies: "; … … 955 961 956 962 it = viewCells.begin(); 963 964 for (int j = 0; j < intervals; ++ j) 965 { 966 float volDif = 0; 967 int smallerDif = 0; 968 969 while ((i < (int)viewCells.size()) && 970 (viewCells[i]->GetPvsCost() < currentPvs)) 971 { 972 volDif += viewCells[i]->GetVolume(); 973 volSum += viewCells[i]->GetVolume(); 974 975 ++ i; 976 ++ smallerDif; 977 ++ smallerSum; 978 } 979 980 // if (0 && (i < (int)viewCells.size())) 981 // Debug << "new pvs cost increase: " << mViewCellsTree->GetPvsCost(viewCells[i]) 982 // << " " << currentPvs << endl; 983 984 const float volRatioDif = volDif / totalVol; 985 const float volRatioSum = volSum / totalVol; 986 987 outstream << "#Pass\n" << j << endl; 988 outstream << "#Pvs\n" << currentPvs << endl; 989 outstream << "#ViewCellsDif\n" << smallerDif << endl; 990 outstream << "#ViewCellsSum\n" << smallerSum << endl; 991 outstream << "#VolumeDif\n" << volRatioDif << endl << endl; 992 outstream << "#VolumeSum\n" << volRatioSum << endl << endl; 993 994 //-- increase current pvs size to define next interval 995 currentPvs += stepSize; 996 } 997 998 outstream.close(); 999 } 1000 1001 1002 void ViewCellsManager::EvalViewCellHistogramForPvsSize(const string filename, 1003 ViewCellContainer &viewCells) 1004 { 1005 std::ofstream outstream; 1006 outstream.open(filename.c_str()); 1007 1008 float maxPvs, maxVal, minVal; 1009 1010 // sort by pvs size 1011 sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 1012 1013 maxPvs = viewCells.back()->GetPvsCost(); 1014 minVal = 0; 1015 1016 // hack: normalize pvs size 1017 int histoMaxVal; 1018 Environment::GetSingleton()->GetIntValue("Preprocessor.histogram.maxValue", histoMaxVal); 1019 maxVal = max((float)histoMaxVal, maxPvs); 1020 1021 Debug << "histogram minpvssize: " << minVal << " maxpvssize: " << maxVal 1022 << " real maxpvs " << maxPvs << endl; 1023 1024 int histoIntervals; 1025 Environment::GetSingleton()->GetIntValue("Preprocessor.histogram.intervals", histoIntervals); 1026 const int intervals = min(histoIntervals, (int)viewCells.size()); 1027 1028 const float range = maxVal - minVal; 1029 int stepSize = (int)(range / intervals); 1030 1031 // set step size to avoid endless loop 1032 if (!stepSize) stepSize = 1; 1033 1034 Debug << "intervals " << histoIntervals << endl; 1035 Debug << "stepsize: " << stepSize << endl; 1036 cout << "intervals " << histoIntervals << endl; 1037 cout << "stepsize: " << stepSize << endl; 1038 1039 const float totalRenderCost = mViewCellsTree->GetRoot()->GetRenderCost(); 1040 const float totalVol = GetViewSpaceBox().GetVolume(); 1041 1042 float currentPvs = minVal; 1043 1044 int i = 0; 1045 int j = 0; 1046 float volSum = 0; 1047 int smallerSum = 0; 1048 1049 //ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 957 1050 958 1051 for (int j = 0; j < intervals; ++ j) … … 6031 6124 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.stepSize", splitsStepSize); 6032 6125 6126 bool useHisto; 6127 int histoMem; 6128 6129 Environment::GetSingleton()->GetBoolValue("ViewCells.Evaluation.histogram", useHisto); 6130 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.histoMem", histoMem); 6131 6033 6132 Debug << "step size: " << splitsStepSize << endl; 6034 6133 Debug << "view cell evaluation samples per pass: " << samplesPerPass << endl; … … 6047 6146 6048 6147 // mix of sampling strategies 6049 evalStrats.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION); 6050 6051 /*evalStrats.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 6052 evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 6053 evalStrats.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 6054 */ 6055 //evalStrats.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 6148 if (0) 6149 { 6150 evalStrats.push_back(SamplingStrategy::OBJECT_DIRECTION_BASED_DISTRIBUTION); 6151 } 6152 else 6153 { 6154 /*evalStrats.push_back(SamplingStrategy::OBJECT_BASED_DISTRIBUTION); 6155 evalStrats.push_back(SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION); 6156 evalStrats.push_back(SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION); 6157 */ 6158 evalStrats.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 6159 } 6056 6160 6057 6161 Debug << "casting eval strategies: "; … … 6064 6168 cout << evalStrats[i] << " "; 6065 6169 cout << endl; 6170 6171 int pass = 0; 6066 6172 6067 6173 while (castSamples < numSamples) … … 6122 6228 6123 6229 ofstream ofstr(filename.c_str()); 6124 mHierarchyManager->EvaluateSubdivision2(ofstr, splitsStepSize, false );6230 mHierarchyManager->EvaluateSubdivision2(ofstr, splitsStepSize, false, useHisto, histoMem, pass); 6125 6231 6126 6232 timeDiff = TimeDiff(startTime, GetTime()); … … 6167 6273 << (float)pvsSize * ObjectPvs::GetEntrySize() << endl; 6168 6274 } 6275 ++ pass; 6169 6276 } 6170 6277 … … 6174 6281 //////////// 6175 6282 //-- histogram 6176 6283 #if 1 6177 6284 const int numLeaves = mViewCellsTree->GetNumInitialViewCells(mViewCellsTree->GetRoot()); 6178 bool useHisto;6179 6285 int histoStepSize; 6180 6286 … … 6185 6291 { 6186 6292 // evaluate view cells in a histogram 6187 char s [64];6293 char str[64]; 6188 6294 6189 6295 // hack: just show final view cells … … 6195 6301 6196 6302 cout << "computing histogram for " << pass << " view cells" << endl; 6197 #if 0 6198 //-- evaluate histogram for render cost 6199 sprintf(s, "-%09d-histo.log", pass); 6200 filename = string(statsPrefix) + string(s); 6201 6202 EvalViewCellHistogram(filename, pass); 6203 6204 #endif 6303 6205 6304 ////////////////////////////////////////// 6206 6305 //-- evaluate histogram for pvs size … … 6208 6307 cout << "computing pvs histogram for " << pass << " view cells" << endl; 6209 6308 6210 sprintf(s , "-%09d-histo-pvs.log", pass);6211 filename = string(statsPrefix) + string(s );6309 sprintf(str, "-%09d-histo-pvs2.log", pass); 6310 filename = string(statsPrefix) + string(str); 6212 6311 6213 6312 EvalViewCellHistogramForPvsSize(filename, pass); 6214 6313 } 6215 6314 } 6216 }6217 6218 6315 #endif 6219 6220 6221 6222 } 6316 } 6317 6318 #endif 6319 6320 6321 6322 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1903 r1919 440 440 void EvalViewCellHistogramForPvsSize(const string filename, const int nViewCells); 441 441 442 void EvalViewCellHistogramForPvsSize(const string filename, 443 ViewCellContainer &viewCells); 444 442 445 /** Evaluates the render cost of a view cell. 443 446 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1918 r1919 2949 2949 2950 2950 mTotalCost = vData.mCorrectedRenderCost = vData.mRenderCost = pvsCost; 2951 mPvsEntries = vData.mCorrectedPvs = vData.mPvs = EvalPvsEntriesSize(rays); 2951 mPvsEntries = EvalPvsEntriesSize(rays); 2952 vData.mCorrectedPvs = vData.mPvs = (float)mPvsEntries; 2952 2953 2953 2954 //////////////
Note: See TracChangeset
for help on using the changeset viewer.