Changeset 1761 for GTP/trunk/Lib/Vis
- Timestamp:
- 11/16/06 15:41:44 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1760 r1761 27 27 #define USE_VOLUMES_FOR_HEURISTICS 1 28 28 29 int BvhNode::sMailId = 10000; //2147483647;30 int BvhNode::sReservedMailboxes = 1;29 //int BvhNode::sMailId = 10000; //2147483647; 30 //int BvhNode::sReservedMailboxes = 1; 31 31 32 32 BvHierarchy *BvHierarchy::BvhSubdivisionCandidate::sBvHierarchy = NULL; … … 1871 1871 if (!object) 1872 1872 return NULL; 1873 1874 1873 return object->mBvhLeaf; 1875 1874 … … 2397 2396 nodeStack.pop(); 2398 2397 2399 if (node->IsLeaf()) 2400 { 2401 BvhLeaf *leaf = (BvhLeaf *)node; 2402 if (Overlap(box, leaf->GetBoundingBox())) { 2403 Intersectable *object = leaf; 2404 if (!object->Mailed()) { 2405 object->Mail(); 2406 objects.push_back(object); 2407 } 2398 if (node->IsLeaf()) 2399 { 2400 BvhLeaf *leaf = (BvhLeaf *)node; 2401 if (Overlap(box, leaf->GetBoundingBox())) { 2402 Intersectable *object = leaf; 2403 if (!object->Mailed()) { 2404 object->Mail(); 2405 objects.push_back(object); 2406 } 2407 } 2408 } 2409 else 2410 { 2411 BvhInterior *interior = (BvhInterior *)node; 2412 2413 if (Overlap(box, interior->GetBoundingBox())) 2414 nodeStack.push(interior->GetFront()); 2415 2416 if (Overlap(box, interior->GetBoundingBox())) 2417 nodeStack.push(interior->GetBack()); 2408 2418 } 2409 } 2410 else 2411 { 2412 BvhInterior *interior = (BvhInterior *)node; 2413 2414 if (Overlap(box, interior->GetBoundingBox())) 2415 nodeStack.push(interior->GetFront()); 2416 2417 if (Overlap(box, interior->GetBoundingBox())) 2418 nodeStack.push(interior->GetBack()); 2419 } 2420 } 2421 } 2422 2423 } 2419 } 2420 } 2421 2422 } -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1758 r1761 206 206 //-- mailing options 207 207 208 static void NewMail(const int reserve = 1) {209 sMailId += sReservedMailboxes;210 sReservedMailboxes = reserve;211 }212 213 void Mail() { mMailbox = sMailId; }214 bool Mailed() const { return mMailbox == sMailId; }215 216 void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }217 bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }218 219 int IncMail() { return ++ mMailbox - sMailId; }220 221 static int sMailId;222 //int mMailbox;223 static int sReservedMailboxes;208 // static void NewMail(const int reserve = 1) { 209 // sMailId += sReservedMailboxes; 210 // sReservedMailboxes = reserve; 211 // } 212 213 // void Mail() { mMailbox = sMailId; } 214 // bool Mailed() const { return mMailbox == sMailId; } 215 216 // void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 217 // bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 218 219 // int IncMail() { return ++ mMailbox - sMailId; } 220 221 // static int sMailId; 222 // //int mMailbox; 223 // static int sReservedMailboxes; 224 224 225 225 -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1757 r1761 1464 1464 RegisterOption("ViewCells.processOnlyValidViewCells", 1465 1465 optBool, 1466 "view_cells_process_only_valid_view_cells =",1466 "view_cells_process_only_valid_view_cells", 1467 1467 "false"); 1468 1468 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1736 r1761 21 21 22 22 23 KdNode::KdNode(KdInterior *parent):mParent(parent), mMailbox(0) 23 KdNode::KdNode(KdInterior *parent):mParent(parent), mMailbox(0), mIntersectable(NULL) 24 24 25 { 25 26 if (parent) … … 1405 1406 if (node == NULL) 1406 1407 return NULL; 1407 1408 // search nodes 1409 std::map<KdNode *, KdIntersectable *>:: 1410 const_iterator it = mKdIntersectables.find(node); 1411 1412 if (it != mKdIntersectables.end()) 1413 { 1414 return (*it).second; 1415 } 1416 1417 // not in map => create new entry 1418 KdIntersectable *kdObj = new KdIntersectable(node, GetBox(node)); 1419 mKdIntersectables[node] = kdObj; 1420 1421 return kdObj; 1408 1409 if (node->mIntersectable == NULL) { 1410 // not in map => create new entry 1411 node->mIntersectable = new KdIntersectable(node, GetBox(node)); 1412 mKdIntersectables.push_back(node->mIntersectable); 1413 } 1414 1415 return node->mIntersectable; 1422 1416 } 1423 1417 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r1633 r1761 101 101 static int sReservedMailboxes; 102 102 int mMailbox; 103 104 KdIntersectable *mIntersectable; 103 105 104 106 void Mail() { mMailbox = sMailId; } … … 596 598 public: 597 599 /// stores the kd node intersectables used for pvs 598 KdIntersectableMapmKdIntersectables;599 600 vector<KdIntersectable *> mKdIntersectables; 601 600 602 }; 601 603 -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r1757 r1761 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: T ue Nov 14 23:59:0720063 # Generated by qmake (2.00a) (Qt 4.1.2) on: Thu Nov 16 14:37:00 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1737 r1761 525 525 } 526 526 527 mVssRays.PrintStatistics(mStats);528 mViewCellsManager->PrintPvsStatistics(mStats);529 527 530 528 // viewcells->UpdatePVS(newVssRays); … … 534 532 mViewCellsManager->SetValidityPercentage(0, 1.0f); 535 533 Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 536 534 535 mVssRays.PrintStatistics(mStats); 536 mViewCellsManager->PrintPvsStatistics(mStats); 537 537 538 ComputeRenderError(); 538 539 } -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp
r1757 r1761 144 144 } 145 145 146 146 CLEAR_CONTAINER(vssRays); 147 147 148 if (samples > mTotalSamples) 148 149 break; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1732 r1761 245 245 } 246 246 247 static bool GreaterOrEqualPvs(const ViewCell *a, const ViewCell *b) { 248 return !SmallerPvs(a, b); 249 } 250 247 251 static bool SmallerRenderCost(const ViewCell *a, const ViewCell *b) 248 252 { … … 267 271 float GetMergeCost() const; 268 272 273 274 float GetCachedPvsCost() const { 275 return mPvsCost; 276 } 269 277 270 278 ////////// … … 483 491 */ 484 492 float GetPvsCost(ViewCell *vc) const; 493 485 494 486 495 /** Returns number of entries associated with this view cell. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1760 r1761 32 32 33 33 // $$JB HACK 34 #define USE_KD_PVS 035 #define KD_PVS_AREA ( 5*1e-4f)34 #define USE_KD_PVS 1 35 #define KD_PVS_AREA (1e-4f) 36 36 37 37 … … 87 87 { 88 88 // visualization stuff 89 Environment::GetSingleton()->GetBoolValue("ViewCells.Visualization.exportRays", mExportRays);89 Environment::GetSingleton()->GetBoolValue("ViewCells.Visualization.exportRays", mExportRays); 90 90 Environment::GetSingleton()->GetBoolValue("ViewCells.Visualization.exportGeometry", mExportGeometry); 91 91 Environment::GetSingleton()->GetFloatValue("ViewCells.maxPvsRatio", mMaxPvsRatio); … … 317 317 ViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const 318 318 { 319 #if USE_KD_PVS 320 float area = GetPreprocessor()->mKdTree->GetBox().SurfaceArea()*KD_PVS_AREA; 321 KdNode *node = GetPreprocessor()->mKdTree->GetNode(isTermination ? 322 ray.mTermination : ray.mOrigin, 323 area); 324 return 325 GetPreprocessor()->mKdTree-> 326 GetOrCreateKdIntersectable(node); 327 #else 319 328 return isTermination ? ray.mTerminationObject : ray.mOriginObject; 329 #endif 320 330 } 321 331 … … 794 804 stream << "<BoundingBoxes>" << endl; 795 805 #if USE_KD_PVS 796 KdIntersectableMap::const_iterator kit, kit_end = GetPreprocessor()->mKdTree->mKdIntersectables.end();806 vector<KdIntersectable *>::iterator kit, kit_end = GetPreprocessor()->mKdTree->mKdIntersectables.end(); 797 807 798 808 int id = 0; 799 809 for (kit = GetPreprocessor()->mKdTree->mKdIntersectables.begin(); kit != kit_end; ++ kit, ++ id) 800 810 { 801 Intersectable *obj = (*kit).second;802 803 804 805 806 807 808 811 Intersectable *obj = *kit; 812 const AxisAlignedBox3 box = obj->GetBox(); 813 814 obj->SetId(id); 815 816 stream << "<BoundingBox" << " id=\"" << id << "\"" 817 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 818 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 809 819 } 810 820 #else 811 ObjectContainer::const_iterator oit, oit_end = objects.end();812 821 ObjectContainer::const_iterator oit, oit_end = objects.end(); 822 813 823 for (oit = objects.begin(); oit != oit_end; ++ oit) 814 824 { … … 955 965 float &contribution) const 956 966 { 957 if (!obj) return false; 958 967 if (!obj) 968 return false; 969 959 970 // potentially visible objects 960 971 return vc->AddPvsSample(obj, pdf, contribution); … … 1401 1412 ) 1402 1413 { 1403 sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 1404 1405 int start = (int)(mViewCells.size() * minValid); 1406 int end = (int)(mViewCells.size() * maxValid); 1407 1408 for (int i = 0; i < (int)mViewCells.size(); ++ i) 1409 { 1410 mViewCells[i]->SetValid(i >= start && i <= end); 1414 ObjectPvs dummyPvs; 1415 // update pvs sizes 1416 for (int i = 0; i < (int)mViewCells.size(); ++ i) { 1417 UpdatePvsForEvaluation(mViewCells[i], dummyPvs); 1418 } 1419 1420 sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 1421 1422 int start = (int)(mViewCells.size() * minValid); 1423 int end = (int)(mViewCells.size() * maxValid); 1424 1425 for (int i = 0; i < (int)mViewCells.size(); ++ i) 1426 { 1427 // cout<<"pvs:"<<mViewCells[i]->GetCachedPvsCost()<<endl; 1428 mViewCells[i]->SetValid(i >= start && i <= end); 1411 1429 } 1412 1430 } … … 1821 1839 stat.avgFilteredPvs = 0.0f; 1822 1840 stat.avgFilterContribution = 0.0f; 1841 stat.avgFilterRadius = 0; 1842 stat.avgFilterRatio = 0; 1823 1843 1824 1844 for (; it != mViewCells.end(); ++ it) 1825 1845 { 1826 1846 ViewCell *viewcell = *it; 1827 1828 const float pvsCost = mViewCellsTree->GetPvsCost(viewcell); 1829 1830 if (pvsCost < stat.minPvs) 1831 stat.minPvs = pvsCost; 1832 if (pvsCost > stat.maxPvs) 1833 stat.maxPvs = pvsCost; 1834 1835 stat.avgPvs += pvsCost; 1836 1837 const bool evaluateFilter = true; 1838 1839 if (evaluateFilter) { 1840 ObjectPvs filteredPvs = viewcell->GetPvs(); 1841 ApplyFilter2(viewcell, false, 1.0f, filteredPvs); 1842 float filteredCost = filteredPvs.EvalPvsCost(); 1843 stat.avgFilteredPvs += filteredCost; 1844 stat.avgFilterContribution += filteredCost - pvsCost; 1845 } else { 1846 stat.avgFilteredPvs += pvsCost; 1847 stat.avgFilterContribution += 0; 1847 if (viewcell->GetValid()) { 1848 const float pvsCost = mViewCellsTree->GetPvsCost(viewcell); 1849 1850 if (pvsCost < stat.minPvs) 1851 stat.minPvs = pvsCost; 1852 if (pvsCost > stat.maxPvs) 1853 stat.maxPvs = pvsCost; 1854 1855 stat.avgPvs += pvsCost; 1856 1857 const bool evaluateFilter = true; 1858 1859 if (evaluateFilter) { 1860 ObjectPvs filteredPvs = viewcell->GetPvs(); 1861 PvsFilterStatistics fstat = ApplyFilter2(viewcell, false, 1.0f, filteredPvs); 1862 1863 float filteredCost = filteredPvs.EvalPvsCost(); 1864 stat.avgFilteredPvs += filteredCost; 1865 stat.avgFilterContribution += filteredCost - pvsCost; 1866 1867 stat.avgFilterRadius += fstat.mAvgFilterRadius; 1868 stat.avgFilterRatio += fstat.mLocalFilterCount / (float) fstat.mGlobalFilterCount; 1869 1870 1871 } else { 1872 stat.avgFilteredPvs += pvsCost; 1873 stat.avgFilterContribution += 0; 1874 } 1875 1876 ++ stat.viewcells; 1848 1877 } 1849 1850 ++ stat.viewcells;1851 1878 } 1852 1879 … … 1855 1882 stat.avgFilteredPvs/=stat.viewcells; 1856 1883 stat.avgFilterContribution/=stat.viewcells; 1884 stat.avgFilterRadius/=stat.viewcells; 1885 stat.avgFilterRatio/=stat.viewcells; 1857 1886 } 1858 1887 } … … 1867 1896 s<<"#AVG_FILTERED_PVS\n"<<pvsStat.avgFilteredPvs<<endl; 1868 1897 s<<"#AVG_FILTER_CONTRIBUTION\n"<<pvsStat.avgFilterContribution<<endl; 1898 s<<"#AVG_FILTER_RADIUS\n"<<pvsStat.avgFilterRadius<<endl; 1899 s<<"#AVG_FILTER_RATIO\n"<<pvsStat.avgFilterRatio<<endl; 1869 1900 s<<"#MAX_PVS\n"<<pvsStat.maxPvs<<endl; 1870 1901 s<<"#MIN_PVS\n"<<pvsStat.minPvs<<endl; … … 1985 2016 return; 1986 2017 1987 #if USE_KD_PVS 1988 float area = GetPreprocessor()->mKdTree->GetBox().SurfaceArea()*KD_PVS_AREA; 1989 KdNode *node = GetPreprocessor()->mKdTree->GetNode(ray.mTermination, area); 1990 Intersectable *obj = 1991 GetPreprocessor()->mKdTree-> 1992 GetOrCreateKdIntersectable(node); 1993 #else 1994 Intersectable *obj = ray.mTerminationObject; 1995 #endif 2018 Intersectable *obj = GetIntersectable(ray, true); 1996 2019 1997 2020 for (it = viewcells->begin(); it != viewcells->end(); ++it) { … … 2037 2060 ray.mViewCells = viewcells; 2038 2061 } 2039 2040 #if USE_KD_PVS 2041 float area = GetPreprocessor()->mKdTree->GetBox().SurfaceArea()*KD_PVS_AREA; 2042 KdNode *node = GetPreprocessor()->mKdTree->GetNode(ray.mTermination, area); 2043 Intersectable *obj = 2044 GetPreprocessor()->mKdTree-> 2045 GetOrCreateKdIntersectable(node); 2046 #else 2047 Intersectable *obj = ray.mTerminationObject; 2048 #endif 2062 2063 Intersectable *obj = GetIntersectable(ray, true); 2049 2064 2050 2065 … … 2590 2605 2591 2606 2592 void 2607 PvsFilterStatistics 2593 2608 ViewCellsManager::ApplyFilter2(ViewCell *viewCell, 2594 2609 const bool useViewSpaceFilter, … … 2597 2612 ) 2598 2613 { 2614 PvsFilterStatistics stats; 2615 2599 2616 AxisAlignedBox3 vbox = GetViewCellBox(viewCell); 2600 2617 Vector3 center = vbox.Center(); 2601 2602 2618 // COpy the PVS 2603 2619 ObjectPvs basePvs = viewCell->GetPvs(); … … 2606 2622 ObjectPvsIterator pit = basePvs.GetIterator(); 2607 2623 2624 #if !USE_KD_PVS 2608 2625 // first mark all object from this pvs 2609 2626 while (pit.HasMoreEntries()) { … … 2613 2630 object->Mail(); 2614 2631 } 2615 2632 #endif 2616 2633 2617 2634 int pvsSize = 0; 2618 2635 int nPvsSize = 0; 2619 float samples = (float)pvs.GetSamples(); 2620 2621 // cout<<"#s"<<samples<<endl; 2622 // cout<<"pvs size = "<<pvs.GetSize() <<endl; 2636 float samples = (float)basePvs.GetSamples(); 2637 2638 cout<<"f #s="<<samples<<"pvs size = "<<basePvs.GetSize(); 2623 2639 // cout<<"Filter size = "<<filterSize<<endl; 2624 2640 // cout<<"vbox = "<<vbox<<endl; … … 2635 2651 #define MIN_LOCAL_SAMPLES 5 2636 2652 2637 float globalC = 2.0f*filterSize/sqrt(samples);2638 2653 float viewCellRadius = 0.5f*Magnitude(vbox.Diagonal()); 2639 2654 … … 2659 2674 // update samples and globalC 2660 2675 samples = (float)pvs.GetSamples(); 2661 globalC = 2.0f*filterSize/sqrt(samples);2662 2676 // cout<<"neighboring viewcells = "<<i-1<<endl; 2663 2677 // cout<<"Samples' = "<<samples<<endl; 2664 2678 } 2679 2680 // Minimal number of samples so that filtering takes place 2681 #define MIN_SAMPLES 100 2682 if (samples > MIN_SAMPLES) { 2683 float globalC = 2.0f*filterSize/sqrt(samples); 2684 2685 pit = basePvs.GetIterator(); 2686 2687 ObjectContainer objects; 2688 2689 while (pit.HasMoreEntries()) 2690 { 2691 ObjectPvsEntry entry = pit.Next(); 2692 2693 Intersectable *object = entry.mObject; 2694 // compute filter size based on the distance and the numebr of samples 2695 AxisAlignedBox3 box = object->GetBox(); 2696 2697 float distance = Distance(center, box.Center()); 2698 float globalRadius = distance*globalC; 2699 2700 int objectSamples = (int)entry.mData.mSumPdf; 2701 float localRadius = MAX_FLOAT; 2702 if (objectSamples > MIN_LOCAL_SAMPLES) 2703 localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/ 2704 sqrt((float)objectSamples); 2705 2706 // cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 2707 2708 // now compute the filter size 2709 float radius; 2710 2711 if (localRadius < globalRadius) { 2712 radius = localRadius; 2713 stats.mLocalFilterCount++; 2714 } else { 2715 radius = globalRadius; 2716 stats.mGlobalFilterCount++; 2717 } 2718 2719 stats.mAvgFilterRadius += radius; 2720 2721 // cout<<"box = "<<box<<endl; 2722 // cout<<"distance = "<<distance<<endl; 2723 // cout<<"radiues = "<<radius<<endl; 2724 2725 box.Enlarge(Vector3(radius)); 2726 2727 objects.clear(); 2728 // $$ warning collect objects takes only unmailed ones! 2729 CollectObjects(box, objects); 2730 // cout<<"collected objects="<<objects.size()<<endl; 2731 ObjectContainer::const_iterator noi = objects.begin(); 2732 for (; noi != objects.end(); ++ noi) { 2733 Intersectable *o = *noi; 2734 // $$ JB warning: pdfs are not correct at this point! 2735 pvs.AddSampleDirty(o, Limits::Small); 2736 } 2737 } 2738 stats.mAvgFilterRadius /= (stats.mLocalFilterCount + stats.mGlobalFilterCount); 2739 } 2665 2740 2666 pit = basePvs.GetIterator(); 2667 2668 ObjectContainer objects; 2669 2670 while (pit.HasMoreEntries()) 2671 { 2672 ObjectPvsEntry entry = pit.Next(); 2673 2674 Intersectable *object = entry.mObject; 2675 // compute filter size based on the distance and the numebr of samples 2676 AxisAlignedBox3 box = object->GetBox(); 2677 2678 float distance = Distance(center, box.Center()); 2679 float globalRadius = distance*globalC; 2680 2681 int objectSamples = (int)entry.mData.mSumPdf; 2682 float localRadius = MAX_FLOAT; 2683 if (objectSamples > MIN_LOCAL_SAMPLES) 2684 localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/ 2685 sqrt((float)objectSamples); 2686 2687 // cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 2688 2689 // now compute the filter size 2690 float radius = Min(localRadius, globalRadius); 2691 2692 // cout<<"box = "<<box<<endl; 2693 // cout<<"distance = "<<distance<<endl; 2694 // cout<<"radiues = "<<radius<<endl; 2695 2696 box.Enlarge(Vector3(radius)); 2697 2698 objects.clear(); 2699 // $$ warning collect objects takes only unmailed ones! 2700 CollectObjects(box, objects); 2701 // cout<<"collected objects="<<objects.size()<<endl; 2702 ObjectContainer::const_iterator noi = objects.begin(); 2703 for (; noi != objects.end(); ++ noi) { 2704 Intersectable *o = *noi; 2705 // $$ JB warning: pdfs are not correct at this point! 2706 pvs.AddSampleDirty(o, Limits::Small); 2707 } 2708 } 2709 2710 // cout<<"nPvs size = "<<pvs.GetSize()<<endl; 2711 2741 cout<<" nPvs size = "<<pvs.GetSize()<<endl; 2742 2743 #if !USE_KD_PVS 2712 2744 // copy the base pvs to the new pvs 2713 2745 pit = basePvs.GetIterator(); … … 2716 2748 pvs.AddSampleDirty(entry.mObject, entry.mData.mSumPdf); 2717 2749 } 2750 #endif 2718 2751 2719 2752 Intersectable::NewMail(); 2753 return stats; 2720 2754 } 2721 2755 … … 5096 5130 VspOspViewCellsManager::GetIntersectable(const VssRay &ray, const bool isTermination) const 5097 5131 { 5132 #if USE_KD_PVS 5133 return ViewCellsManager::GetIntersectable(ray, isTermination); 5134 #else 5098 5135 return mHierarchyManager->GetIntersectable(ray, isTermination); 5136 #endif 5099 5137 } 5100 5138 … … 5853 5891 ViewCellContainer::const_iterator it = viewcells.begin(); 5854 5892 5893 Intersectable *terminationObj = GetIntersectable(ray, true); 5894 Intersectable *originObj = GetIntersectable(ray, false); 5895 5855 5896 for (; it != viewcells.end(); ++ it) 5856 5897 { … … 5861 5902 float contribution; 5862 5903 5863 if ( ray.mTerminationObject)5904 if (terminationObj) 5864 5905 { 5865 5906 // todo: maybe not correct for kd node pvs 5866 Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 5867 5868 if (viewcell->GetPvs().GetSampleContribution(obj, 5869 ray.mPdf, 5870 contribution)) 5907 5908 if (viewcell->GetPvs().GetSampleContribution(terminationObj, 5909 ray.mPdf, 5910 contribution)) 5871 5911 { 5872 5912 ++ ray.mPvsContribution; 5873 5913 } 5874 5875 5914 5915 ray.mRelativePvsContribution += contribution; 5876 5916 } 5877 5917 5878 5918 //////////////// 5879 5919 //-- for directional sampling it is important to count only contributions … … 5881 5921 //-- the other contributions of this sample will be counted for the opposite ray! 5882 5922 #if SAMPLE_ORIGIN_OBJECTS 5883 if ( ray.mOriginObject&&5884 viewcell->GetPvs().GetSampleContribution( ray.mOriginObject,5885 ray.mPdf,5886 contribution))5887 {5923 if (originObj && 5924 viewcell->GetPvs().GetSampleContribution(originObj, 5925 ray.mPdf, 5926 contribution)) 5927 { 5888 5928 ++ ray.mPvsContribution; 5889 5929 ray.mRelativePvsContribution += contribution; 5890 }5930 } 5891 5931 #endif 5892 5932 } … … 5906 5946 break; 5907 5947 5948 //$$JB hack 5949 #if !USE_KD_PVS 5908 5950 AddSampleToPvs( 5909 ray.mTerminationObject, 5910 ray.mTermination, 5911 viewCell, 5912 ray.mPdf, 5913 ray.mRelativePvsContribution); 5914 5951 terminationObj, 5952 ray.mTermination, 5953 viewCell, 5954 ray.mPdf, 5955 ray.mRelativePvsContribution); 5956 #else 5957 viewCell->GetPvs().AddSample(terminationObj, ray.mPdf); 5958 #endif 5959 5915 5960 #if SAMPLE_ORIGIN_OBJECTS 5916 5917 5961 AddSampleToPvs( 5918 ray.mOriginObject,5919 ray.mOrigin,5920 viewCell,5921 ray.mPdf,5922 ray.mRelativePvsContribution);5962 originObj, 5963 ray.mOrigin, 5964 viewCell, 5965 ray.mPdf, 5966 ray.mRelativePvsContribution); 5923 5967 #endif 5924 5968 } 5925 5969 5926 5970 5927 5971 … … 5937 5981 float &contribution) const 5938 5982 { 5939 5940 5983 // The hierarchy manager decides about the type of sample cast 5984 return mHierarchyManager->AddSampleToPvs(obj, hitPoint, vc, pdf, contribution); 5941 5985 } 5942 5986 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1760 r1761 42 42 struct BspRay; 43 43 44 44 struct PvsFilterStatistics { 45 PvsFilterStatistics(): mAvgFilterRadius(0.0f), mLocalFilterCount(0), mGlobalFilterCount(0) {} 46 float mAvgFilterRadius; 47 int mLocalFilterCount; 48 int mGlobalFilterCount; 49 50 }; 51 45 52 /** Probably Visible Set 46 53 */ … … 69 76 float avgFilteredPvs; 70 77 float avgFilterContribution; 78 float avgFilterRadius; 79 float avgFilterRatio; 71 80 int viewcells; 81 72 82 }; 73 83 … … 466 476 467 477 // TODO: write own visibiltiy filter class 468 478 void ApplyFilter(KdTree *kdTree, 469 479 const float viewSpaceFilterSize, 470 480 const float spatialFilterSize); 471 481 472 482 // new adaptive version of the filter 473 void483 PvsFilterStatistics 474 484 ApplyFilter2(ViewCell *viewCell, 475 485 const bool useViewSpaceFilter, -
GTP/trunk/Lib/Vis/Preprocessing/src/default.env
r1757 r1761 81 81 RssPreprocessor { 82 82 samplesPerPass 1000 83 initialSamples 200000083 initialSamples 3000000 84 84 vssSamples 50000000 85 85 # vssSamples 1000000 … … 205 205 maxPvsRatio 1.0 206 206 207 processOnlyValidViewCells false207 processOnlyValidViewCells true 208 208 209 209 #stats viewCellStats.log
Note: See TracChangeset
for help on using the changeset viewer.