- Timestamp:
- 01/24/06 10:06:58 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r568 r573 30 30 VssPreprocessor { 31 31 samplesPerPass 100000 32 initialSamples 200000032 initialSamples 6000000 33 33 vssSamples 0 34 34 vssSamplesPerPass 500000 -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r563 r573 118 118 ); 119 119 120 virtual void CastRays(SimpleRayContainer &rays, 121 VssRayContainer &vssRays) {}; 122 120 123 /// scene graph loaded from file 121 124 SceneGraph *mSceneGraph; -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h
r556 r573 133 133 std::map<T, PvsData<T>, LtSample<T> >::const_iterator it; 134 134 135 mEntries = a.mEntries; 135 136 // todo: copy all elements instead of inserting 136 for (it = a.mEntries.begin(); it != a.mEntries.end(); ++ it)137 mEntries.insert(*it);137 //for (it = a.mEntries.begin(); it != a.mEntries.end(); ++ it) 138 // mEntries.insert(*it); 138 139 139 140 for (it = b.mEntries.begin(); it != b.mEntries.end(); ++ it) -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r556 r573 201 201 } 202 202 203 203 204 bool BspLeaf::IsLeaf() const 204 205 { … … 206 207 } 207 208 208 /****************************************************************/ 209 /* class BspTree implementation */ 210 /****************************************************************/ 209 210 /******************************************************************/ 211 /* class BspTree implementation */ 212 /******************************************************************/ 211 213 212 214 BspTree::BspTree(): -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r572 r573 88 88 89 89 90 int ViewCellsManager::CastPassSamples(int samplesPerPass, 91 int sampleType, 92 VssRayContainer *outRays) const 93 { 94 VssRayContainer passSamples; 95 SimpleRayContainer simpleRays; 96 97 preprocessor->GenerateRays(samplesPerPass, 98 sampleType, 99 simpleRays); 100 101 // shoot simple ray and add it to importance samples 102 preprocessor->CastRays(simpleRays, passSamples); 103 104 const int numSamples = (int)passSamples.size(); 105 106 if (outRays) 107 { 108 while (!passSamples.empty()) 109 outRays->push_back(passSamples.back()); 110 } 111 else 112 { 113 CLEAR_CONTAINER(passSamples); 114 } 115 116 return numSamples; 117 } 118 119 90 120 int ViewCellsManager::Construct(Preprocessor *preprocessor, VssRayContainer *outRays) 91 121 { 122 int numSamples = 0; 92 123 SimpleRayContainer simpleRays; 93 VssRayContainer constructionRays; 94 95 preprocessor->GenerateRays(mConstructionSamples, 96 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION, 97 simpleRays); 98 99 Construct(preprocessor->mObjects, constructionRays); 100 101 int numRays = (int)simpleRays.size(); 102 103 static Ray traversalRay; 104 105 // shoot simple ray and add it to construction rays 106 while (!simpleRays.empty()) 107 { 108 SimpleRay sray = simpleRays.back(); 109 110 // TODO: shoot into kdtree 111 constructionRays.push_back(new VssRay(traversalRay)); 112 113 if (outRays) 114 outRays->push_back(constructionRays.back()); 115 116 simpleRays.pop_back(); 117 } 118 119 if (!outRays) 120 CLEAR_CONTAINER(constructionRays); 121 122 // guided rays 123 VssRayContainer importanceRays; 124 const int desiredImportanceRays = max(1000000, mPostProcessSamples); 125 preprocessor->GenerateRays(desiredImportanceRays, 126 Preprocessor::RSS_BASED_DISTRIBUTION, 127 simpleRays); 128 129 numRays += (int)simpleRays.size(); 130 131 // shoot simple ray and add it to construction rays 132 while (!simpleRays.empty()) 133 { 134 SimpleRay sray = simpleRays.back(); 135 136 // TODO: shoot into kdtree 137 importanceRays.push_back(new VssRay(traversalRay)); 138 139 if (outRays) 140 outRays->push_back(importanceRays.back()); 141 142 simpleRays.pop_back(); 143 } 144 145 if (!outRays) 146 CLEAR_CONTAINER(importanceRays); 147 124 125 VssRayContainer constructionSamples; 126 127 //-- construction rays => we use uniform samples for this 128 CastPassSamples(mConstructionSamples, 129 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION, 130 &constructionSamples); 131 132 // construct view cells 133 const int initialSamples = Construct(preprocessor->mObjects, constructionSamples); 134 135 numSamples += initialSamples; 136 137 if (outRays) 138 { 139 while (!constructionSamples.empty()) 140 outRays->push_back(constructionSamples.back()); 141 } 142 else 143 { 144 CLEAR_CONTAINER(constructionSamples); 145 } 146 147 148 //-- guided rays are used for further sampling 149 const int desiredImportanceSamples = 5000000; 150 const int importanceRayPerPass = 1000000; 151 152 const int n = desiredImportanceSamples; //+initialSamples; 153 154 while (numSamples < n) 155 { 156 numSamples += CastPassSamples(importanceRayPerPass, 157 Preprocessor::RSS_BASED_DISTRIBUTION, 158 //Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION, 159 outRays); 160 } 161 162 163 //-- post processing 164 VssRayContainer postProcessSamples; 165 166 //-- construction rays => we use uniform samples for this 167 CastPassSamples(max(mPostProcessSamples, mVisualizationSamples), 168 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION, 169 &postProcessSamples); 170 148 171 // merge the view cells 149 PostProcess(preprocessor->mObjects, importanceRays); 150 151 Visualize(preprocessor->mObjects, importanceRays); 152 153 154 return numRays; 172 PostProcess(preprocessor->mObjects, postProcessSamples); 173 // several visualizations 174 Visualize(preprocessor->mObjects, postProcessSamples); 175 176 if (outRays) 177 { 178 while (!postProcessSamples.empty()) 179 outRays->push_back(postProcessSamples.back()); 180 } 181 else 182 { 183 CLEAR_CONTAINER(postProcessSamples); 184 } 185 186 return numSamples; 155 187 } 156 188 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r570 r573 306 306 protected: 307 307 308 int CastPassSamples(int samplesPerPass, 309 int sampleType, 310 VssRayContainer *outRays) const; 311 308 312 void ParseEnvironment(); 309 313 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r570 r573 942 942 else 943 943 { 944 nCostRatio[axis] = SplitPlaneCost(Plane3(normal, nPosition[axis]), 945 tData, *nFrontGeom[axis], *nBackGeom[axis], 946 nProbFront[axis], nProbBack[axis]); 944 nCostRatio[axis] = 945 EvalSplitPlaneCost(Plane3(normal, nPosition[axis]), 946 tData, *nFrontGeom[axis], *nBackGeom[axis], 947 nProbFront[axis], nProbBack[axis]); 947 948 } 948 949 } … … 1123 1124 float fArea, bArea; 1124 1125 plane = poly->GetSupportingPlane(); 1125 candidateCost = SplitPlaneCost(plane, data, fGeom, bGeom, fArea, bArea);1126 candidateCost = EvalSplitPlaneCost(plane, data, fGeom, bGeom, fArea, bArea); 1126 1127 1127 1128 if (candidateCost < lowestCost) … … 1263 1264 1264 1265 1265 float VspBspTree:: SplitPlaneCost(const Plane3 &candidatePlane,1266 const VspBspTraversalData &data,1267 BspNodeGeometry &geomFront,1268 BspNodeGeometry &geomBack,1269 float &pFront,1270 float &pBack) const1266 float VspBspTree::EvalSplitPlaneCost(const Plane3 &candidatePlane, 1267 const VspBspTraversalData &data, 1268 BspNodeGeometry &geomFront, 1269 BspNodeGeometry &geomBack, 1270 float &pFront, 1271 float &pBack) const 1271 1272 { 1272 1273 float cost = 0; … … 1377 1378 if (mSplitPlaneStrategy & PVS) 1378 1379 { 1379 const float oldCost = pOverall * (float)totalPvs + Limits::Small; 1380 cost += mPvsFactor * (pvsFront * pFront + pvsBack * pBack) / oldCost; 1380 if (1) 1381 { 1382 const float oldCost = pOverall * (float)totalPvs + Limits::Small; 1383 cost += mPvsFactor * (pvsFront * pFront + pvsBack * pBack) / oldCost; 1384 } 1385 else 1386 { 1387 // try to equalize render differences 1388 const float oldCost = pOverall * (float)totalPvs + Limits::Small; 1389 float newCost = fabs(pvsFront * pFront - pvsBack * pBack); 1390 1391 cost += mPvsFactor * newCost / oldCost; 1392 } 1381 1393 } 1382 1394 … … 2573 2585 } 2574 2586 2587 // important so other merge candidates sharing this view cell 2588 // are notified that the merge cost must be updated!! 2575 2589 vc->Mail(); 2576 2590 2577 // clean up old view cells2591 //-- clean up old view cells 2578 2592 if (mExportMergedViewCells) 2579 2593 { … … 2581 2595 DEL_PTR(bVc); 2582 2596 } 2583 else // throw them into old view cells container 2584 { 2597 else 2598 { 2599 // old view cells container needed for visualization 2585 2600 //fVc->mMailbox = -1; 2586 2601 //bVc->mMailbox = -1; … … 3204 3219 return 1e15f; 3205 3220 3221 #if 1 3206 3222 float p1, p2; 3207 3223 … … 3217 3233 } 3218 3234 3219 const float cost1 = (float)pvs1;// * p1; 3220 const float cost2 = (float)pvs2;// * p2; 3235 const float cost1 = pvs1 * p1; 3236 const float cost2 = pvs2 * p2; 3237 #else 3238 const float cost1 = pvs1; 3239 const float cost2 = pvs2; 3240 #endif 3221 3241 3222 3242 return cost1 + cost2; … … 3270 3290 BspViewCell *vc2 = leaf2->GetViewCell(); 3271 3291 3272 float cost1 = vc1->GetPvs().GetSize();3273 float cost2 = vc2->GetPvs().GetSize(); 3274 3275 /*if (mUseAreaForPvs)3292 float cost1, cost2; 3293 3294 #if 1 3295 if (mUseAreaForPvs) 3276 3296 { 3277 3297 cost1 = vc1->GetPvs().GetSize() * vc1->GetArea(); … … 3282 3302 cost1 = vc1->GetPvs().GetSize() * vc1->GetVolume(); 3283 3303 cost2 = vc2->GetPvs().GetSize() * vc2->GetVolume(); 3284 }*/ 3304 } 3305 #else 3306 cost1 = vc1->GetPvs().GetSize(); 3307 cost2 = vc2->GetPvs().GetSize(); 3308 #endif 3285 3309 3286 3310 const float oldCost = cost1 + cost2; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r564 r573 411 411 @returns the cost of the candidate split plane 412 412 */ 413 float SplitPlaneCost(const Plane3 &candidatePlane,414 const VspBspTraversalData &data,415 BspNodeGeometry &geomFront,416 BspNodeGeometry &geomBack,417 float &pFront,418 float &pBack) const;413 float EvalSplitPlaneCost(const Plane3 &candidatePlane, 414 const VspBspTraversalData &data, 415 BspNodeGeometry &geomFront, 416 BspNodeGeometry &geomBack, 417 float &pFront, 418 float &pBack) const; 419 419 420 420 /** Subdivide leaf.
Note: See TracChangeset
for help on using the changeset viewer.