Changeset 2690 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 05/20/08 17:15:44 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
r2689 r2690 17 17 VIEWPOINTS=../data/vienna/testwalk.vp 18 18 19 LOG_PREFIX=../src/SG08/t estwalk_cropped19 LOG_PREFIX=../src/SG08/try 20 20 #LOG_PREFIX=../src/SG08/city_full_100 21 21 … … 30 30 -scene_filename=$SCENE \ 31 31 -preprocessor=gvs \ 32 -preprocessor_use_vbos +\32 -preprocessor_use_vbos- \ 33 33 -gvs_epsilon=0.0001 \ 34 34 -gvs_total_samples=1000000 \ … … 36 36 -gvs_initial_samples=16 \ 37 37 -gvs_max_viewcells=1 \ 38 -gvs_min_contribution=1 00 \38 -gvs_min_contribution=1500 \ 39 39 -gvs_per_viewcell=true \ 40 40 -gvs_stats=$LOG_PREFIX-gvsStats.log \ -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2689 r2690 667 667 668 668 //glFinish(); 669 #if 0670 //-- now issue queries for all objects671 for (int j = 0; j < (int)mObjects.size(); ++ j)672 {673 mOcclusionQueries[j]->BeginQuery();674 RenderIntersectable(mObjects[j]);675 mOcclusionQueries[j]->EndQuery();676 677 unsigned int pixelCount;678 679 pixelCount = mOcclusionQueries[j]->GetQueryResult();680 681 mObjects[j]->mCounter += pixelCount;682 }683 #else684 685 669 int q = 0; 686 670 … … 703 687 704 688 //-- reenable other state 705 #if 0706 bool available;707 708 do709 {710 available = mOcclusionQueries[t]->ResultAvailable();711 712 if (!available) cout << "W";713 }714 while (!available);715 #endif716 689 717 690 pixelCount = mOcclusionQueries[t]->GetQueryResult(); … … 722 695 723 696 } 724 725 //j += q; 726 } 727 #endif 697 } 698 728 699 //glFinish(); 729 700 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); … … 873 844 874 845 875 876 877 void 878 GlRendererBuffer::EvalRenderCostSample(RenderCostSample &sample, 879 const bool useOcclusionQueries, 880 const int threshold 881 ) 846 void GlRendererBuffer::EvalRenderCostSample(RenderCostSample &sample, 847 const bool useOcclusionQueries, 848 const int threshold) 882 849 { 883 850 // choose a random view point … … 902 869 903 870 for (it = mObjects.begin(); it != it_end; ++ it) 904 {905 871 (*it)->mCounter = 0; 906 907 }908 872 909 873 ++ mFrame; -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2689 r2690 152 152 #endif 153 153 { 154 //cout << "r";155 154 // apply reverse sampling to find the gap 156 155 VssRay *newRay = ReverseSampling(currentRay, hitTriangle, oldRay); … … 160 159 161 160 // set flag for visualization 162 //newRay->mFlags |= VssRay::ReverseSample;161 if (0) newRay->mFlags |= VssRay::ReverseSample; 163 162 164 163 // check if ray is not further processed (ray not deleted because using ray pool) … … 185 184 void GvsPreprocessor::UpdateStatsForVisualization(KdIntersectable *kdInt) 186 185 { 187 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt);186 //mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 188 187 189 188 // count new objects in pvs due to kd node conversion … … 222 221 223 222 // counter < 2 => not accounted for yet 224 if (obj->mCounter < ACCOUNTED_OBJECT) 223 // test of triangle was accounted for yet 224 if (result = AddTriangleObject(obj)) 225 225 { 226 obj->mCounter += ACCOUNTED_OBJECT;227 mTrianglePvs.push_back(obj);228 229 mGenericStats = (int)mTrianglePvs.size();230 231 226 // exchange the triangle with the node in the pvs for kd pvs 232 227 if (mUseKdPvs) … … 664 659 665 660 while (!mRayQueue.empty())//&& (mGvsStats.mTotalSamples + castSamples < mTotalSamples) ) 666 {//cout<<"r"; 667 //cout << "queue size: " << mRayQueue.size() << endl; 661 { 668 662 // handle next ray 669 663 VssRay *ray = mRayQueue.top(); … … 794 788 795 789 796 void GvsPreprocessor::ProcessViewCell()797 {798 // compute object that directly intersect view cell799 IntersectWithViewCell();800 801 mGvsStats.mPerViewCellSamples = 0;802 803 int oldContribution = mGvsStats.mTotalContribution;804 int passSamples = 0;805 806 mGenericStats = 0;807 mGenericStats2 = 0;808 809 while (1)810 {811 mRayCaster->InitPass();812 813 // Ray queue empty =>814 // cast a number of uniform samples to fill ray queue815 int newSamples = CastInitialSamples(mInitialSamples, mSamplingType);816 817 if (!mOnlyRandomSampling)818 {819 int samplesPerRun = ProcessQueue();820 newSamples += samplesPerRun;821 //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " ";822 }823 824 passSamples += newSamples;825 mGvsStats.mPerViewCellSamples += newSamples;826 827 if (passSamples >= mGvsSamplesPerPass)828 {829 ++ mPass;830 mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution;831 832 ////////833 //-- stats834 835 mGvsStats.mPass = mPass;836 837 cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl;838 cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl;839 840 //mGenericStats = mGvsStats.mPassContribution;841 842 // termination criterium843 if (mGvsStats.mPassContribution < mMinContribution)844 break;845 846 // reset847 oldContribution = mGvsStats.mTotalContribution;848 mGvsStats.mPassContribution = 0;849 passSamples = 0;850 }851 }852 }853 854 855 790 void GvsPreprocessor::CompileViewCellsFromPointList() 856 791 { … … 945 880 } 946 881 947 #if 0882 #if 1 948 883 void GvsPreprocessor::IntersectWithViewCell() 949 884 { … … 1066 1001 void GvsPreprocessor::PerViewCellComputation() 1067 1002 { 1068 ViewCell *vc; 1069 1070 while (vc = NextViewCell()) 1003 while (mCurrentViewCell = NextViewCell()) 1071 1004 { 1072 1005 // hack: reset counters … … 1076 1009 (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 1077 1010 1078 ComputeViewCell( vc);1011 ComputeViewCell(); 1079 1012 } 1080 1013 } … … 1088 1021 continue; 1089 1022 1090 ViewCell *vc= mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint());1023 mCurrentViewCell = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint()); 1091 1024 1092 1025 // no valid view cell or view cell already computed 1093 if (! vc || !vc->GetPvs().Empty() || !mRendererWidget->mComputeGVS)1026 if (!mCurrentViewCell || !mCurrentViewCell->GetPvs().Empty() || !mRendererWidget->mComputeGVS) 1094 1027 continue; 1095 1028 … … 1101 1034 (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 1102 1035 1103 ComputeViewCell( vc);1036 ComputeViewCell(); 1104 1037 ++ mProcessedViewCells; 1105 1038 } … … 1322 1255 app << "#Id\n" << mViewCellId << endl; 1323 1256 app << "#Time\n" << mTimePerViewCell << endl;; 1324 app << "#Tri aePvs\n" << mTrianglePvs << endl;1257 app << "#TriPvs\n" << mTrianglePvs << endl; 1325 1258 app << "#ObjectPvs\n" << mPerViewCellPvs << endl; 1326 1259 app << "#UpdatedPvs\n" << (int)mPvsCost << endl; … … 1351 1284 1352 1285 1353 void GvsPreprocessor::ComputeViewCell( ViewCell *vc)1286 void GvsPreprocessor::ComputeViewCell() 1354 1287 { 1355 1288 KdNode::NewMail(); 1356 1289 1357 mCurrentViewCell = vc;1358 1359 1290 const long startTime = GetTime(); 1360 1291 … … 1364 1295 1365 1296 // compute the pvs of the current view cell 1366 ProcessViewCell(); 1367 1368 1297 // compute object that directly intersect view cell 1298 //IntersectWithViewCell(); 1299 1300 mGvsStats.mPerViewCellSamples = 0; 1301 1302 int oldContribution = mGvsStats.mTotalContribution; 1303 int passSamples = 0; 1304 1305 mGenericStats = 0; 1306 mGenericStats2 = 0; 1307 1308 while (1) 1309 { 1310 int oldPvsSize = 0;//mCurrentViewCell->GetPvs().GetSize(); 1311 1312 mRayCaster->InitPass(); 1313 1314 // Ray queue empty => 1315 // cast a number of uniform samples to fill ray queue 1316 int newSamples = CastInitialSamples(mInitialSamples, mSamplingType); 1317 1318 if (!mOnlyRandomSampling) 1319 { 1320 int samplesPerRun = ProcessQueue(); 1321 newSamples += samplesPerRun; 1322 //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " "; 1323 } 1324 1325 passSamples += newSamples; 1326 mGvsStats.mPerViewCellSamples += newSamples; 1327 1328 if (passSamples >= mGvsSamplesPerPass) 1329 { 1330 if (GVS_DEBUG) VisualizeViewCell(mTrianglePvs); 1331 1332 const bool convertPerPass = false; 1333 1334 if (convertPerPass) 1335 { 1336 int newObjects = ConvertObjectPvs(); 1337 1338 cout << "added " << newObjects << " triangles to triangle pvs" << endl; 1339 mGvsStats.mTotalContribution += newObjects; 1340 } 1341 1342 ++ mPass; 1343 mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution; 1344 1345 1346 //////// 1347 //-- stats 1348 1349 mGvsStats.mPass = mPass; 1350 1351 cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl; 1352 cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl; 1353 cout << "obj contri=" << mCurrentViewCell->GetPvs().GetSize() - oldPvsSize << " (of " << mMinContribution << ")" << endl; 1354 1355 // termination criterium 1356 if (mGvsStats.mPassContribution < mMinContribution) 1357 break; 1358 1359 // reset 1360 oldContribution = mGvsStats.mTotalContribution; 1361 mGvsStats.mPassContribution = 0; 1362 passSamples = 0; 1363 } 1364 } 1365 1366 // finally add objects that directly intersect the view cell 1367 //IntersectWithViewCell(); 1368 1369 1369 1370 //////// 1370 1371 //-- stats 1371 1372 1373 // timing 1374 mGvsStats.mTimePerViewCell = TimeDiff(startTime, GetTime()) * 1e-3f; 1375 1376 ComputeStats(); 1377 1378 // clean up 1379 mTrianglePvs.clear(); 1380 } 1381 1382 1383 void GvsPreprocessor::ComputeStats() 1384 { 1372 1385 // compute pvs size using larger (bvh objects) 1373 1386 // note: for kd pvs we had to do this during gvs computation … … 1402 1415 1403 1416 mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 1404 1405 // timing1406 const long currentTime = GetTime();1407 mGvsStats.mTimePerViewCell = TimeDiff(startTime, currentTime) * 1e-3f;1408 1417 1409 1418 … … 1411 1420 // global values 1412 1421 1413 mGvsStats.mViewCells = mProcessedViewCells; //mPass;1422 mGvsStats.mViewCells = mProcessedViewCells; 1414 1423 mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 1415 1424 mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; … … 1421 1430 1422 1431 cout << "id: " << mCurrentViewCell->GetId() << " pvs cost: " 1423 << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl; 1424 1425 1426 mTrianglePvs.clear(); 1427 } 1428 1429 } 1432 << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl; 1433 } 1434 1435 1436 ObjectContainer triangles; 1437 1438 int GvsPreprocessor::ConvertObjectPvs() 1439 { 1440 int newObjects = 0; 1441 1442 ObjectPvsIterator pit = mCurrentViewCell->GetPvs().GetIterator(); 1443 1444 triangles.clear(); 1445 1446 // output PVS of view cell 1447 while (pit.HasMoreEntries()) 1448 { 1449 KdIntersectable *kdInt = static_cast<KdIntersectable *>(pit.Next()); 1450 1451 mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), triangles); 1452 1453 ObjectContainer::const_iterator oit, oit_end = triangles.end(); 1454 1455 for (oit = triangles.begin(); oit != oit_end; ++ oit) 1456 { 1457 if (AddTriangleObject(*oit)) 1458 ++ newObjects; 1459 } 1460 } 1461 1462 return newObjects; 1463 } 1464 1465 1466 bool GvsPreprocessor::AddTriangleObject(Intersectable *triObj) 1467 { 1468 if ((triObj->mCounter < ACCOUNTED_OBJECT)) 1469 { 1470 triObj->mCounter += ACCOUNTED_OBJECT; 1471 1472 mTrianglePvs.push_back(triObj); 1473 mGenericStats = (int)mTrianglePvs.size(); 1474 return true; 1475 } 1476 1477 return false; 1478 } 1479 1480 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r2687 r2690 231 231 void StorePvs(const ObjectContainer &objectPvs); 232 232 233 /** Compute visibility for a given view cell. 234 */ 235 void ComputeViewCell(ViewCell *vc); 236 /** Runs gvs on the current view cell. 237 */ 238 void ProcessViewCell(); 233 /** Compute visibility for the current view cell using gvs 234 */ 235 void ComputeViewCell(); 239 236 /** Use this for qt visualization. 240 237 */ … … 245 242 246 243 void CompileViewCellsFromPointList(); 244 245 bool AddTriangleObject(Intersectable *triObj); 246 247 void ComputeStats(); 248 249 int ConvertObjectPvs(); 247 250 248 251 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r2677 r2690 1155 1155 1156 1156 1157 void KdTree::CollectObjectsWith outMail(KdNode *n, ObjectContainer &objects)1157 void KdTree::CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects) 1158 1158 { 1159 1159 stack<KdNode *> nodeStack; -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r2670 r2690 403 403 void 404 404 CollectObjects(KdNode *n, ObjectContainer &objects); 405 void 406 CollectObjectsWithoutMail(KdNode *n, ObjectContainer &objects); 407 void 408 CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 405 406 /** Collects objects with dublicates (no mailing going on) 407 */ 408 void CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects); 409 void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 409 410 410 411 void -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2678 r2690 2373 2373 2374 2374 2375 void ViewCellsManager::UpdateStatsForViewCell(ViewCell *vc, Intersectable *obj) 2376 { 2375 void ViewCellsManager::UpdateStatsForViewCell(ViewCell *vc, Intersectable *obj, int numTriangles) 2376 { 2377 #ifdef USE_VERBOSE_PVS 2377 2378 KdIntersectable *kdObj = static_cast<KdIntersectable *>(obj); 2378 2379 … … 2399 2400 2400 2401 //cout << "x " << radius << " " << dist << " " << fullRadius << " " << f << " " << f * f << endl; 2401 2402 const int numTriangles = kdObj->ComputeNumTriangles(); 2403 #ifdef USE_VERBOSE_PVS 2402 //const int numTriangles = kdObj->ComputeNumTriangles(); 2403 2404 2404 vc->GetPvs().mStats.mDistanceWeightedTriangles += f * numTriangles; 2405 2405 vc->GetPvs().mStats.mDistanceWeightedPvs += f ; … … 2427 2427 bool hasAbsContribution; 2428 2428 2429 // todo: maybenot correct for kd node pvs2429 // todo: probably not correct for kd node pvs 2430 2430 if (addSamplesToPvs) 2431 2431 { … … 2433 2433 //hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf); 2434 2434 2435 if (hasAbsContribution) 2436 { 2437 UpdateStatsForViewCell(viewCell, obj); 2438 } 2435 //if (hasAbsContribution) UpdateStatsForViewCell(viewCell, obj); 2436 2439 2437 } 2440 2438 else … … 6195 6193 const int colorCode = 0; 6196 6194 6197 const float maxRenderCost = -1; //UpdateObjectCosts();6195 const float maxRenderCost = -1; 6198 6196 const bool exportBounds = false; 6199 6197 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r2638 r2690 584 584 585 585 586 void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj );586 void UpdateStatsForViewCell(ViewCell *viewCell, Intersectable *obj, int numTriangles); 587 587 588 588
Note: See TracChangeset
for help on using the changeset viewer.