- Timestamp:
- 11/15/05 01:32:10 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r410 r411 67 67 ViewCells { 68 68 #hierarchy kdTree 69 hierarchy vspTree 69 70 hierarchy bspTree 70 71 # hierarchy sceneDependent … … 201 202 epsilon 1e-6 202 203 203 maxDepth 40 204 minPvs 1 205 minRays 50 206 minSize 0.00001 207 maxCostRatio 0.95 208 maxRayContribution 0.05 204 Construction { 205 samples 100000 206 } 207 208 Termination { 209 maxDepth 40 210 minPvs 1 211 minRays 50 212 minSize 0.00001 213 maxCostRatio 0.95 214 maxRayContribution 0.05 215 } 209 216 210 217 maxTotalMemory 400 … … 212 219 213 220 splitType regular 214 # splitType heuristics215 221 216 222 numberOfEndPointDomains 10000 217 223 ct_div_ci 0.0 218 randomize false 219 220 refDirBoxMaxSize 0.1 221 } 224 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r409 r411 1336 1336 1337 1337 1338 RegisterOption("VspKdTree.maxDepth", optInt, "kd_depth=", "12"); 1339 RegisterOption("VspKdTree.minPvs", optInt, "kd_minpvs=", "1"); 1340 RegisterOption("VspKdTree.minRays", optInt, "kd_minrays=", "10"); 1341 RegisterOption("VspKdTree.maxCostRatio", optFloat, "maxcost=", "0.95"); 1342 RegisterOption("VspKdTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5"); 1343 1344 RegisterOption("VspKdTree.epsilon", optFloat, "kd_eps=", "1e-6"); 1345 RegisterOption("VspKdTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0"); 1346 RegisterOption("VspKdTree.randomize", optBool, "randomize", "false"); 1347 RegisterOption("VspKdTree.splitType", optString, "split=", "queries"); 1348 RegisterOption("VspKdTree.numberOfEndPointDomains", optInt, "endpoints=", "10000"); 1349 1350 RegisterOption("VspKdTree.minSize", optFloat, "minsize=", "0.001"); 1351 1352 RegisterOption("VspKdTree.maxTotalMemory", optFloat, "mem=", "60.0"); 1353 RegisterOption("VspKdTree.maxStaticMemory", optFloat, "statmem=", "8.0"); 1354 1355 RegisterOption("VspKdTree.queryType", optString, "qtype=", "static"); 1356 1357 RegisterOption("VspKdTree.queryPosWeight", optFloat, "qposweight=", "0.0"); 1358 RegisterOption("VspKdTree.useRefDirSplits", optBool, "refdir", "false"); 1359 RegisterOption("VspKdTree.refDirAngle", optFloat, "refangle=", "10"); 1360 RegisterOption("VspKdTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1"); 1361 RegisterOption("VspKdTree.accessTimeThreshold", optInt, "accesstime=", "1000"); 1362 RegisterOption("VspKdTree.minCollapseDepth", optInt, "colldepth=", "4"); 1363 1364 RegisterOption("VssTree.maxDepth", optInt, "kd_depth=", "12"); 1338 RegisterOption("VspKdTree.Construction.Samples", 1339 optInt, 1340 "-vsp_construction_samples=", 1341 "100000"); 1342 1343 RegisterOption("VspKdTree.Termination.maxDepth", 1344 optInt, 1345 "vsp_depth=", "30"); 1346 1347 RegisterOption("VspKdTree.Termination.minPvs", 1348 optInt, 1349 "vsp_minpvs=", 1350 "1"); 1351 1352 RegisterOption("VspKdTree.Termination.minRays", 1353 optInt, 1354 "vsp_minrays=", 1355 "10"); 1356 1357 RegisterOption("VspKdTree.maxCostRatio", 1358 optFloat, 1359 "vsp_maxcost=", 1360 "0.95"); 1361 1362 RegisterOption("VspKdTree.maxRayContribution", 1363 optFloat, 1364 "vsp_max_ray_contrib=", 1365 "0.5"); 1366 1367 RegisterOption("VspKdTree.epsilon", 1368 optFloat, 1369 "kd_eps=", 1370 "1e-6"); 1371 1372 RegisterOption("VspKdTree.ct_div_ci", 1373 optFloat, 1374 "vsp_ctdivci=", "1.0"); 1375 1376 RegisterOption("VspKdTree.splitType", 1377 optString, 1378 "split=", 1379 "queries"); 1380 1381 RegisterOption("VspKdTree.numberOfEndPointDomains", 1382 optInt, 1383 "endpoints=", 1384 "10000"); 1385 1386 RegisterOption("VspKdTree.minSize", 1387 optFloat, 1388 "minsize=", 1389 "0.001"); 1390 1391 RegisterOption("VspKdTree.maxTotalMemory", 1392 optFloat, 1393 "vsp_max_total_mem=", 1394 "60.0"); 1395 1396 RegisterOption("VspKdTree.maxStaticMemory", 1397 optFloat, 1398 "vsp_max_static_mem=", 1399 "8.0"); 1400 1401 RegisterOption("VspKdTree.queryType", 1402 optString, 1403 "qtype=", 1404 "static"); 1405 1406 RegisterOption("VspKdTree.queryPosWeight", 1407 optFloat, 1408 "qposweight=", 1409 "0.0"); 1410 1411 RegisterOption("VspKdTree.accessTimeThreshold", 1412 optInt, 1413 "accesstime=", 1414 "1000"); 1415 1416 RegisterOption("VspKdTree.minCollapseDepth", 1417 optInt, 1418 "vsp_min_colldepth=", 1419 "4"); 1420 1421 RegisterOption("VssTree.maxDepth", optInt, "kd_depth=", "12"); 1365 1422 RegisterOption("VssTree.minPvs", optInt, "kd_minpvs=", "1"); 1366 1423 RegisterOption("VssTree.minRays", optInt, "kd_minrays=", "10"); -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r410 r411 62 62 { 63 63 ViewCell::sHierarchy = ViewCell::KD; 64 } 65 else if (strcmp(viewCellsStr, "vspTree") == 0) 66 { 67 ViewCell::sHierarchy = ViewCell::VSP; 64 68 } 65 69 else if (strcmp(viewCellsStr, "sceneDependent") == 0) -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r409 r411 9 9 #include "ViewCellBsp.h" 10 10 #include "ViewCell.h" 11 #include "VspKdTree.h" 11 12 12 13 class RenderSimulator; … … 119 120 120 121 RenderSimulator *mRenderSimulator; 122 123 /** Kd tree inducing a coarse partition of view space that are the building 124 blocks for view cells. 125 */ 126 VspKdTree *mVspKdTree; 121 127 }; 122 128 -
trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.h
r409 r411 30 30 { 31 31 public: 32 BspViewCellRenderSimulator(float objRenderCost, float vcOverhead, float moveSpeed, BspTree *bspTree); 32 BspViewCellRenderSimulator(float objRenderCost, 33 float vcOverhead, 34 float moveSpeed, 35 BspTree *bspTree); 33 36 34 37 Real SimulateRendering(); … … 47 50 { 48 51 public: 49 KdViewCellRenderSimulator(float objRenderCost, float vcOverhead, float moveSpeed, KdTree *kdTree); 52 KdViewCellRenderSimulator(float objRenderCost, 53 float vcOverhead, 54 float moveSpeed, 55 KdTree *kdTree); 50 56 Real SimulateRendering(); 51 57 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r410 r411 9 9 #include "RenderSimulator.h" 10 10 11 SamplingPreprocessor::SamplingPreprocessor(): mPass(0) , mSampleRays(NULL)11 SamplingPreprocessor::SamplingPreprocessor(): mPass(0) 12 12 { 13 13 // this should increase coherence of the samples … … 15 15 environment->GetIntValue("Sampling.totalSamples", mTotalSamples); 16 16 environment->GetIntValue("BspTree.Construction.samples", mBspConstructionSamples); 17 environment->GetIntValue("VspTree.Construction.samples", mVspConstructionSamples); 18 17 19 environment->GetIntValue("ViewCells.PostProcessing.samples", mPostProcessSamples); 18 20 environment->GetIntValue("BspTree.Visualization.samples", mVisualizationSamples); … … 25 27 { 26 28 CLEAR_CONTAINER(mSampleRays); 29 CLEAR_CONTAINER(mVspSampleRays); 27 30 } 28 31 … … 198 201 } 199 202 } 200 else 201 { 202 if (ray.kdLeaves.size()) { 203 Intersectable *terminator = 204 ray.intersections.size() ? ray.intersections[0].mObject: NULL; 205 206 sampleContributions += AddNodeSamples(ray, 207 object, 208 terminator); 209 } 210 } 203 else { 204 if (ray.kdLeaves.size()) { 205 Intersectable *terminator = 206 ray.intersections.size() ? ray.intersections[0].mObject: NULL; 207 208 sampleContributions += AddNodeSamples(ray, 209 object, 210 terminator); 211 } 212 } 211 213 212 214 return sampleContributions; … … 482 484 //mVspKdTree->Construct(mSampleRays, mBoundingBox); 483 485 } 484 /*else if (ViewCell::sHierarchy == ViewCell::VSPKD)486 else if (ViewCell::sHierarchy == ViewCell::VSP) 485 487 { 486 ProcessVsp KdViewCells(ray,487 488 489 490 491 } */488 ProcessVspViewCells(ray, 489 reverseSample ? NULL : object, 490 faceIndex, 491 passContributingSamples, 492 passSampleContributions); 493 } 492 494 } 493 495 } else { … … 709 711 } 710 712 713 714 void SamplingPreprocessor::ProcessVspViewCells(const Ray &ray, 715 Intersectable *object, 716 const int faceIndex, 717 int &contributingSamples, 718 int &sampleContributions) 719 { 720 // save rays for bsp tree construction 721 if (!mVspKdTree) 722 { 723 if ((int)mVspSampleRays.size() < mVspConstructionSamples) 724 { 725 MeshInstance *mi = dynamic_cast<MeshInstance *>(object); 726 727 VssRay *sRay = new VssRay(ray); 728 mVspSampleRays.push_back(sRay); 729 730 // also add origin to sample 731 sRay->mOriginObject = object; 732 } 733 else 734 { 735 // construct VSP tree using the collected samples 736 cout << "building VSP tree from " << (int)mVspSampleRays.size() << " samples " << endl; 737 mVspKdTree->Construct(mVspSampleRays); 738 739 // add contributions of saved samples to PVS 740 //contributingSamples += mBspTree->GetStat().contributingSamples; 741 //sampleContributions += mBspTree->GetStat().sampleContributions; 742 743 // throw away samples because BSP leaves not stored in order 744 // Need ordered rays for post processing => collect new rays 745 //CLEAR_CONTAINER(mVspSampleRays); 746 } 747 } 748 // save rays for post processing 749 /*else if (((int)mVspSampleRays.size() < mPostProcessSamples) || 750 ((int)mVspSampleRays.size() < mVisualizationSamples)) 751 { 752 mVspSampleRays.push_back(new Ray(ray)); 753 }*/ 754 } 755 711 756 void SamplingPreprocessor::ProcessBspViewCells(const Ray &ray, 712 757 Intersectable *object, -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h
r409 r411 6 6 7 7 #include "Preprocessor.h" 8 8 #include "VssRay.h" 9 9 10 10 /** Sampling based visibility preprocessing. The implementation is based on heuristical … … 14 14 15 15 SamplingPreprocessor(); 16 17 16 ~SamplingPreprocessor(); 18 17 19 18 virtual bool ComputeVisibility(); 20 19 20 21 21 protected: 22 int mPass;23 24 int mSamplesPerPass;25 int mTotalSamples;26 int mKdPvsDepth;27 ofstream mStats;28 ObjectContainer mObjects;29 RayContainer mSampleRays;30 int mBspConstructionSamples;31 int mPostProcessSamples;32 int mVisualizationSamples;33 34 22 void 35 23 SetupRay(Ray &ray, … … 81 69 int &sampleContributions); 82 70 71 void ProcessVspViewCells(const Ray &ray, 72 Intersectable *object, 73 const int faceIndex, 74 int &contributingSamples, 75 int &sampleContributions); 76 83 77 /** Adds objects samples to bsp view cells. 84 78 */ … … 98 92 */ 99 93 int PostprocessViewCells(const RayContainer &rays); 94 95 protected: 96 int mPass; 97 int mSamplesPerPass; 98 int mTotalSamples; 99 int mKdPvsDepth; 100 ofstream mStats; 101 ObjectContainer mObjects; 102 103 RayContainer mSampleRays; 104 VssRayContainer mVspSampleRays; 105 int mBspConstructionSamples; 106 int mVspConstructionSamples; 107 108 int mPostProcessSamples; 109 int mVisualizationSamples; 110 100 111 }; 101 112 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r372 r411 35 35 */ 36 36 static void DeriveViewCells(const ObjectContainer &objects, 37 38 37 ViewCellContainer &viewCells, 38 const int maxViewCells); 39 39 40 40 … … 62 62 63 63 /// view cells types 64 enum HierarchyType {BSP, KD };64 enum HierarchyType {BSP, KD, VSP}; 65 65 66 66 /** Generates view cells of type specified by view cells type. -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r410 r411 113 113 mPlane(plane), mFront(NULL), mBack(NULL) 114 114 {} 115 116 BspInterior::~BspInterior() 117 { 118 DEL_PTR(mFront); 119 DEL_PTR(mBack); 120 } 115 121 116 122 bool BspInterior::IsLeaf() const … … 375 381 BspTree::~BspTree() 376 382 { 377 std::stack<BspNode *> tStack; 378 379 tStack.push(mRoot); 380 381 while (!tStack.empty()) 382 { 383 BspNode *node = tStack.top(); 384 385 tStack.pop(); 386 387 if (!node->IsLeaf()) 388 { 389 BspInterior *interior = dynamic_cast<BspInterior *>(node); 390 391 // push the children on the stack (there are always two children) 392 tStack.push(interior->GetBack()); 393 tStack.push(interior->GetFront()); 394 } 395 396 DEL_PTR(node); 397 } 383 DEL_PTR(mRoot); 398 384 } 399 385 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r409 r411 244 244 */ 245 245 BspInterior(const Plane3 &plane); 246 ~BspInterior(); 246 247 /** @return false since it is an interior node 247 248 */ -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r410 r411 608 608 609 609 float sum = rr*sizeBox; 610 float minSum = 1e20 ;610 float minSum = 1e20f; 611 611 612 612 Intersectable::NewMail(); … … 706 706 splitCandidates->clear(); 707 707 708 int requestedSize = 2 *(node->rays.size());708 int requestedSize = 2 * (int)(node->rays.size()); 709 709 // creates a sorted split candidates array 710 710 if (splitCandidates->capacity() > 500000 && … … 756 756 757 757 if ((int)(leaf->rays.size()) > stat.maxRayRefs) 758 stat.maxRayRefs = leaf->rays.size();758 stat.maxRayRefs = (int)leaf->rays.size(); 759 759 } 760 760 … … 899 899 900 900 // update stats 901 stat.rayRefs -= leaf->rays.size();901 stat.rayRefs -= (int)leaf->rays.size(); 902 902 stat.rayRefs += raysBack + raysFront; 903 903 … … 1057 1057 if (removeAllScheduledRays) 1058 1058 { 1059 int tail = leaf->rays.size() - 1;1059 int tail = (int)leaf->rays.size() - 1; 1060 1060 1061 1061 for (int i=0; i < (int)(leaf->rays.size()); ++ i) … … 1435 1435 VspKdTreeLeaf *leaf = (VspKdTreeLeaf *)node; 1436 1436 float c = leaf->GetAvgRayContribution(); 1437 int num = ( c*ratioPerLeaf + 0.5);1437 int num = (int)(c*ratioPerLeaf + 0.5); 1438 1438 // cout<<num<<" "; 1439 1439 … … 1457 1457 } 1458 1458 1459 return rays.size();1459 return (int)rays.size(); 1460 1460 } 1461 1461 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h
r410 r411 104 104 105 105 106 // --------------------------------------------------------------107 // For sorting rays108 // --------------------------------------------------------------109 struct SortableEntry110 {111 enum EType {112 ERayMin,113 ERayMax114 };115 116 int type;117 float value;118 void *data;119 120 SortableEntry() {}121 SortableEntry(const int t, const float v, void *d):type(t),122 value(v),123 data(d) {}124 125 friend bool operator<(const SortableEntry &a, const SortableEntry &b) {126 return a.value < b.value;127 }128 };129 130 131 106 class VspKdTreeInterior; 132 107 … … 158 133 #if USE_FIXEDPOINT_T 159 134 #define FIXEDPOINT_ONE 0x7FFE 160 //mMaxT(0xFFFF)161 135 // mMaxT(0xFFFF) 136 mMaxT(FIXEDPOINT_ONE) 162 137 #else 163 138 mMaxT(1.0f) … … 166 141 167 142 RayInfo(VssRay *r, 168 const float _min, 169 const float _max 170 ):mRay(r) { 143 const float _min, 144 const float _max 145 ):mRay(r) 146 { 171 147 SetMinT(_min); 172 148 SetMaxT(_max); … … 174 150 175 151 RayInfo(VssRay *r, 176 177 const float _max178 ):mRay(r), mMinT(_min){152 const short _min, 153 const float _max):mRay(r), mMinT(_min) 154 { 179 155 SetMaxT(_max); 180 156 } 181 157 182 158 RayInfo(VssRay *r, 183 const float _min, 184 const short _max 185 ):mRay(r), mMaxT(_max) { 159 const float _min, 160 const short _max): 161 mRay(r), mMaxT(_max) 162 { 186 163 SetMinT(_min); 187 164 } … … 223 200 224 201 225 int ComputeRayIntersection(const float axis, 226 const float position, 227 float &t 228 ) const { 229 202 int ComputeRayIntersection(const int axis, const float position, float &t) const 203 { 230 204 // intersect the ray with the plane 231 205 float denom = mRay->GetDir(axis); 232 206 233 234 235 207 if (fabs(denom) < 1e-20) 208 //if (denom == 0.0f) 209 return (mRay->GetOrigin(axis) > position) ? 1 : -1; 236 210 237 238 239 240 241 242 243 211 t = (position - mRay->GetOrigin(axis))/denom; 212 213 if (t < GetMinT()) 214 return (denom > 0) ? 1 : -1; 215 216 if (t > GetMaxT()) 217 return (denom > 0) ? -1 : 1; 244 218 245 219 return 0; … … 250 224 251 225 252 253 254 enum { EInterior, ELeaf};226 typedef vector<RayInfo> RayInfoContainer; 227 228 enum {EInterior, ELeaf}; 255 229 256 230 ///////////////////////////////// … … 294 268 // KD-tree node - interior node 295 269 // -------------------------------------------------------------- 296 class VspKdTreeInterior : 297 public VspKdTreeNode 270 class VspKdTreeInterior: public VspKdTreeNode 298 271 { 299 272 public: … … 340 313 virtual int Type() const { return EInterior; } 341 314 342 virtual ~VspKdTreeInterior() { 343 if (back) 344 delete back; 345 if (front) 346 delete front; 347 } 348 349 virtual void Print(ostream &s) const { 350 if (axis == 0) 351 s<<"x "; 352 else 353 if (axis == 1) 354 s<<"y "; 355 else 356 s<<"z "; 357 s<<position<<" "; 358 back->Print(s); 359 front->Print(s); 360 } 361 362 363 364 int ComputeRayIntersection(const RayInfo &rayData, 365 float &t 366 ) { 367 return rayData.ComputeRayIntersection(axis, position, t); 315 virtual ~VspKdTreeInterior() 316 { 317 DEL_PTR(back); 318 DEL_PTR(front); 319 } 320 321 virtual void Print(ostream &s) const 322 { 323 if (axis == 0) 324 s << "x "; 325 else 326 if (axis == 1) 327 s << "y "; 328 else 329 s << "z "; 330 s << position << " "; 331 back->Print(s); 332 front->Print(s); 333 } 334 335 int ComputeRayIntersection(const RayInfo &rayData, float &t) 336 { 337 return rayData.ComputeRayIntersection(axis, position, t); 368 338 } 369 339 … … 465 435 class VspKdTree 466 436 { 437 // -------------------------------------------------------------- 438 // For sorting rays 439 // ------------------------------------------------------------- 440 struct SortableEntry 441 { 442 enum EType 443 { 444 ERayMin, 445 ERayMax 446 }; 447 448 int type; 449 float value; 450 void *data; 451 452 SortableEntry() {} 453 SortableEntry(const int t, const float v, void *d):type(t), 454 value(v), data(d) 455 { 456 } 457 458 friend bool operator<(const SortableEntry &a, const SortableEntry &b) 459 { 460 return a.value < b.value; 461 } 462 }; 463 467 464 struct TraversalData 468 465 { -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h
r410 r411 61 61 } 62 62 63 VccRay(const Ray &ray): 64 VccRay(ray.GetLoc(), ray.Extrap(ray.intersections[0].mT), ray.intersections[0].mObject, ray.sourceObject.mObject) 65 {} 63 VssRay(const Ray &ray) 64 :mOrigin(ray.GetLoc()), 65 mTermination(ray.Extrap(ray.intersections[0].mT)), 66 mOriginObject(ray.sourceObject.mObject), 67 mTerminationObject(ray.intersections[0].mObject), 68 mRefCount(0), 69 mFlags(0), 70 mMailbox(-1) 71 {} 72 66 73 void Precompute() { 67 74 mFlags = 0;
Note: See TracChangeset
for help on using the changeset viewer.