Changeset 1666 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/23/06 15:37:18 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/vsposp_typical.sh
r1664 r1666 102 102 echo "$SCENE $METHOD" 103 103 104 #$PROGRAM $ENVIRONMENT \104 $PROGRAM $ENVIRONMENT \ 105 105 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 106 106 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ … … 134 134 135 135 ############################################################### 136 137 METHOD=gradient- 2136 MEMCONST=1.0 137 METHOD=gradient-$MEMCONST 138 138 echo ********" $SCENE $METHOD ************" 139 139 … … 148 148 -hierarchy_construction_levels=4 \ 149 149 -hierarchy_construction_consider_memory=true \ 150 -hierarchy_term_memory_const=$MEMCONST \ 151 -bvh_construction_render_cost_decrease_weight=0.99 \ 152 -vsp_construction_render_cost_decrease_weight=0.99 \ 153 -hierarchy_construction_recompute_split_on_repair=true 154 155 sh movefiles.sh $LOG_PREFIX-$METHOD 156 157 ######################################################################### 158 159 MEMCONST=0.1 160 METHOD=gradient-$MEMCONST 161 echo ********" $SCENE $METHOD ************" 162 163 $PROGRAM $ENVIRONMENT \ 164 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 165 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 166 -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 167 -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 168 -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 169 -hierarchy_construction_type=2 \ 170 -hierarchy_construction_multilevel=false \ 171 -hierarchy_construction_levels=4 \ 172 -hierarchy_construction_consider_memory=true \ 173 -hierarchy_term_memory_const=$MEMCONST \ 150 174 -bvh_construction_render_cost_decrease_weight=0.99 \ 151 175 -vsp_construction_render_cost_decrease_weight=0.99 \ -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1665 r1666 551 551 //cout << "here7 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 552 552 //priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr();// / mBvhStats.Leaves(); 553 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f);553 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 554 554 } 555 555 } … … 589 589 //cout << "here5 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 590 590 //const float priority = factor * renderCostDecr - (1.0f - factor) * (float)splitCandidate.GetPvsEntriesIncr(); 591 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f);591 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 592 592 } 593 593 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1664 r1666 182 182 void SetParent(BvhInterior *parent); 183 183 184 // collects all objects under this node 184 /** collects all objects under this node. 185 */ 185 186 virtual void CollectObjects(ObjectContainer &objects) = 0; 187 186 188 /** The bounding box specifies the node extent. 187 189 */ … … 190 192 { return mBoundingBox; } 191 193 192 194 /** Sets bouding box of this node. 195 */ 193 196 inline 194 197 void SetBoundingBox(const AxisAlignedBox3 &boundingBox) 195 198 { mBoundingBox = boundingBox; } 196 199 200 201 float GetMergeCost() {return 0.0f; }; 197 202 198 203 ///////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1665 r1666 2537 2537 "1"); 2538 2538 2539 RegisterOption("Hierarchy.Termination.memoryConst", 2540 optFloat, 2541 "hierarchy_term_memory_const=", 2542 "1.0"); 2543 2539 2544 RegisterOption("Hierarchy.Construction.useMultiLevel", 2540 2545 optBool, -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1664 r1666 125 125 "Hierarchy.Termination.maxMemory", mTermMaxMemory); 126 126 127 Environment::GetSingleton()->GetFloatValue( 128 "Hierarchy.Termination.memoryConst", mMemoryConst); 129 127 130 // compare to bytes 128 131 mTermMaxMemory *= (1024.0f * 1024.0f); … … 139 142 Debug << "maximal allowed memory: " << mTermMaxMemory << endl; 140 143 Debug << "consider mem: " << mConsiderMemory << endl; 144 Debug << "mem const: " << mMemoryConst << endl; 141 145 142 146 switch (mConstructionType) -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1663 r1666 530 530 */ 531 531 bool mConsiderMemory; 532 533 float mMemoryConst; 532 534 }; 533 535 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1660 r1666 1525 1525 { 1526 1526 TraversalQueue tqueue; 1527 1528 1527 tqueue.push(mRoot); 1528 1529 1529 int numViewCells = 1; 1530 1530 … … 1535 1535 const int rootEntries = GetPvsEntries(mRoot); 1536 1536 1537 Debug << "******** Export stats **********" << endl;1537 cout << "exporting stats ... " << endl; 1538 1538 1539 1539 float totalRenderCost, avgRenderCost, expectedCost; … … 2151 2151 { 2152 2152 TraversalQueue tqueue; 2153 2154 2153 tqueue.push(mRoot); 2155 2154 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1660 r1666 5512 5512 { 5513 5513 ViewCell *viewcell = *it; 5514 5514 5515 5515 if (viewcell->GetValid()) 5516 5516 { // if ray not outside of view space … … 5519 5519 if (ray.mTerminationObject) 5520 5520 { 5521 5522 5523 5524 5525 5526 5521 // todo: maybe not correct for kd node pvs 5522 Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 5523 5524 if (viewcell->GetPvs().GetSampleContribution(obj, 5525 ray.mPdf, 5526 contribution)) 5527 5527 { 5528 5528 ++ ray.mPvsContribution; 5529 5529 } 5530 5531 5530 5531 ray.mRelativePvsContribution += contribution; 5532 5532 } 5533 5534 // for directional sampling it is important to count only contributions5535 // made in one direction!5536 // the other contributions of this sample will be counted for the opposite ray!5533 5534 //-- for directional sampling it is important to count only contributions 5535 //-- made in one direction! 5536 //-- the other contributions of this sample will be counted for the opposite ray! 5537 5537 #if SAMPLE_ORIGIN_OBJECTS 5538 5538 if (ray.mOriginObject && 5539 5539 viewcell->GetPvs().GetSampleContribution(ray.mOriginObject, 5540 5541 5540 ray.mPdf, 5541 contribution)) 5542 5542 { 5543 5543 ++ ray.mPvsContribution; … … 5616 5616 5617 5617 5618 typedef priority_queue<ViewCell *, vector<ViewCell *>, 5619 myless<vector<ViewCell *>::value_type> > ViewCellsQueue; 5620 5621 typedef priority_queue<BvhNode *, vector<BvhNode *>, 5622 myless<vector<BvhNode *>::value_type> > ObjectsQueue; 5623 5624 void VspOspViewCellsManager::ExportStats(const string &mergeStats) 5625 { 5626 ofstream stats; 5627 stats.open(mergeStats.c_str()); 5628 5629 ObjectsQueue objectsQueue; 5630 ViewCellsQueue viewCellsQueue; 5631 5632 objectsQueue.push(mHierarchyManager->mBvHierarchy->GetRoot()); 5633 viewCellsQueue.push(mViewCellsTree->GetRoot()); 5634 5635 int numViewCells = 1; 5636 5637 const AxisAlignedBox3 box = mViewSpaceBox; 5638 const float vol = box.GetVolume(); 5639 5640 const int rootPvs = mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot()); 5641 const int rootEntries = mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot()); 5642 5643 cout << "exporting stats ... " << endl; 5644 5645 float totalRenderCost, avgRenderCost, expectedCost; 5646 5647 float deviation = 0; 5648 int totalPvs = rootPvs; 5649 int entriesInPvs = rootEntries; 5650 5651 totalRenderCost = avgRenderCost = expectedCost = (float)rootPvs; 5652 5653 const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 5654 const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f); 5655 5656 ///////////// 5657 //-- first view cell 5658 5659 /* mViewCellsTree->UpdateStats(stats, 5660 0, 5661 numViewCells, 5662 0, 5663 totalRenderCost, 5664 rootPvs, 5665 expectedCost, 5666 avgRenderCost, 5667 deviation, 5668 totalPvs, 5669 entriesInPvs, 5670 memoryCost, 5671 0, 5672 mRoot->GetVolume()); 5673 */ 5674 5675 //-- go through tree in the order of render cost decrease 5676 //-- which is the same order as the view cells were merged 5677 //-- or the reverse order of subdivision for subdivision-only 5678 //-- view cell hierarchies. 5679 5680 while (!(objectsQueue.empty() && viewCellsQueue.empty())) 5681 { 5682 ViewCell *viewCell = viewCellsQueue.top(); 5683 BvhNode *bvhNode = objectsQueue.top(); 5684 5685 if (viewCell->GetMergeCost() < bvhNode->GetMergeCost()) 5686 { 5687 viewCellsQueue.pop(); 5688 /* 5689 if (!vc->IsLeaf()) 5690 { 5691 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 5692 5693 const int parentPvs = GetPvsSize(interior); 5694 const int parentPvsEntries = GetPvsEntries(interior); 5695 const float parentCost = (float)parentPvs * interior->GetVolume(); 5696 5697 float childCost = 0; 5698 int childPvs = 0; 5699 int childPvsEntries = 0; 5700 5701 -- numViewCells; 5702 5703 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 5704 5705 for (it = interior->mChildren.begin(); it != it_end; ++ it) 5706 { 5707 ViewCell *vc = *it; 5708 5709 const int pvsSize = GetPvsSize(vc); 5710 const int pvsEntries = GetPvsEntries(vc); 5711 5712 childCost += (float) pvsSize * vc->GetVolume(); 5713 childPvs += pvsSize; 5714 childPvsEntries += pvsEntries; 5715 5716 tqueue.push(vc); 5717 ++ numViewCells; 5718 } 5719 5720 // update stats for this view cell 5721 const float costDecr = (parentCost - childCost) / vol; 5722 5723 totalRenderCost -= costDecr; 5724 totalPvs += childPvs - parentPvs; 5725 entriesInPvs += childPvsEntries - parentPvsEntries; 5726 5727 expectedCost = totalRenderCost / (float)numViewCells; 5728 avgRenderCost = (float)totalPvs / (float)numViewCells; 5729 5730 const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 5731 const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f); 5732 5733 mViewCellsTree->UpdateStats(stats, 5734 0, 5735 numViewCells, 5736 costDecr, 5737 totalRenderCost, 5738 parentPvs, 5739 expectedCost, 5740 avgRenderCost, 5741 deviation, 5742 totalPvs, 5743 entriesInPvs, 5744 memoryCost, 5745 childPvs - parentPvs, 5746 vc->GetVolume()); 5747 */ 5748 } 5749 else // object space split 5750 { 5751 } 5752 } 5753 5754 stats.close(); 5755 } 5756 5757 5618 5758 #if TEST_EVALUATION 5619 5759 void VspOspViewCellsManager::EvalViewCellPartition() … … 5693 5833 cout << "finished" << endl; 5694 5834 5695 vector<int> storageFunc;5696 mViewCellsTree->GetStorageFunction(storageFunc);5697 5698 vector<float> costFunc;5699 mViewCellsTree->GetCostFunction(costFunc);5700 5701 ofstream outstr("out.txt");5702 5703 for (int i = 0; i < storageFunc.size(); ++ i)5704 outstr << i << ": " << storageFunc[i] << endl;5705 outstr << endl;5706 for (int i = 0; i < costFunc.size(); ++ i)5707 outstr << i << ": " << costFunc[i] << endl;5708 if (0)5709 for (int i = 0; i <50; ++ i)5710 {5711 Vector3 point = GetViewSpaceBox().GetRandomPoint();5712 ViewCell *vc = GetViewCell(point);5713 }5714 //RenderBvhNode(mHierarchyManager->mBvHierarchy->GetRoot());5715 5716 5835 disposeRays(evaluationSamples, NULL); 5717 5836 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1662 r1666 1083 1083 1084 1084 ViewCellsManager *LoadViewCells(const string &filename, 1085 ObjectContainer *objects, 1086 const bool finalizeViewCells, 1087 BoundingBoxConverter *bconverter); 1088 1089 bool AddSampleToPvs( 1090 Intersectable *obj, 1091 const Vector3 &hitPoint, 1092 ViewCell *vc, 1093 const float pdf, 1094 float &contribution) const; 1095 1096 void ExportSingleViewCells( 1097 const ObjectContainer &objects, 1098 const int maxViewCells, 1099 const bool sortViewCells, 1100 const bool exportPvs, 1101 const bool exportRays, 1102 const int maxRays, 1103 const string prefix, 1104 VssRayContainer *visRays = NULL); 1085 ObjectContainer *objects, 1086 const bool finalizeViewCells, 1087 BoundingBoxConverter *bconverter); 1088 1089 bool AddSampleToPvs(Intersectable *obj, 1090 const Vector3 &hitPoint, 1091 ViewCell *vc, 1092 const float pdf, 1093 float &contribution) const; 1094 1095 void ExportSingleViewCells(const ObjectContainer &objects, 1096 const int maxViewCells, 1097 const bool sortViewCells, 1098 const bool exportPvs, 1099 const bool exportRays, 1100 const int maxRays, 1101 const string prefix, 1102 VssRayContainer *visRays = NULL); 1105 1103 1106 1104 protected: … … 1112 1110 /** Exports view cell geometry. 1113 1111 */ 1114 void ExportViewCellGeometry( 1115 Exporter *exporter, 1116 ViewCell *vc, 1117 const AxisAlignedBox3 *box, 1118 const AxisAlignedPlane *clipPlane = NULL 1119 ) const; 1120 1121 int ComputeBoxIntersections( 1122 const AxisAlignedBox3 &box, 1123 ViewCellContainer &viewCells) const; 1112 void ExportViewCellGeometry(Exporter *exporter, 1113 ViewCell *vc, 1114 const AxisAlignedBox3 *box, 1115 const AxisAlignedPlane *clipPlane = NULL) const; 1116 1117 int ComputeBoxIntersections(const AxisAlignedBox3 &box, 1118 ViewCellContainer &viewCells) const; 1124 1119 1125 1120 void CollectViewCells(); … … 1135 1130 /** Exports visualization of the PVS. 1136 1131 */ 1137 void ExportPvs( 1138 const ObjectContainer &objects, 1139 const VssRayContainer &rays); 1140 1132 void ExportPvs(const ObjectContainer &objects, const VssRayContainer &rays); 1133 1134 void ExportStats(const string &mergeStats); 1141 1135 1142 1136 ///////////////////////////////////////// -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1665 r1666 828 828 //cout << "here4 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 829 829 //const float priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr(); 830 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + + 1.0f);830 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 831 831 } 832 832 … … 853 853 //cout << "here2 rc: " << factor * renderCostDecr << " pvs: " << (1.0f - factor) * splitCandidate.GetPvsEntriesIncr() << endl; 854 854 //const float priority = factor * renderCostDecr - (1.0f - factor) * splitCandidate.GetPvsEntriesIncr(); 855 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + 1.0f);855 priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mHierarchyManager->mMemoryConst); 856 856 } 857 857
Note: See TracChangeset
for help on using the changeset viewer.