Changeset 2735
- Timestamp:
- 06/04/08 01:49:14 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
r2734 r2735 25 25 26 26 #LOG_PREFIX=../src/SG08/rebut-arena-pixel2 27 LOG_PREFIX=../src/SG08/speedtest 28 LOG_PREFIX=../src/SG08/importance_5.0_10 27 LOG_PREFIX=../src/SG08/probablyvis2 29 28 30 29 ENVIRONMENT=gvs.env … … 43 42 -gvs_samples_per_pass=1000000 \ 44 43 -gvs_initial_samples=16 \ 45 -gvs_max_viewcells=3 0000046 -gvs_min_contribution=10 \44 -gvs_max_viewcells=3 \ 45 -gvs_min_contribution=100 \ 47 46 -gvs_per_viewcell=true \ 48 47 -preprocessor_detect_empty_viewspace+ \ 49 48 -preprocessor_snap_error_frames+ \ 50 -kd_pvs_area=1e- 4\49 -kd_pvs_area=1e-5 \ 51 50 -view_cells_use_kd_pvs+ \ 52 51 -af_use_kd_pvs+ \ -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2732 r2735 70 70 mCurrentViewCell(NULL), 71 71 mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)), 72 mOnlyRandomSampling(false) 73 //mOnlyRandomSampling(true) 72 mOnlyRandomSampling(false), 73 //mOnlyRandomSampling(true), 74 mUseProbablyVisibleSampling(false) 74 75 { 75 76 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); … … 798 799 generationTimer.Entry(); 799 800 800 ViewCellBorderBasedDistribution vcStrat(*this, mCurrentViewCell); 801 GenerateRays(DETERMINISTIC_GVS ? numSamples : numSamples / 16, *mDistribution, simpleRays, sInvalidSamples); 801 if (mUseProbablyVisibleSampling && (RandomValue(0, 1) > 0.5)) 802 { 803 ProbablyVisibleDistribution distr(*this, mCurrentViewCell, &mProbablyVisibleTriangles); 804 GenerateRays(numSamples, distr, simpleRays, sInvalidSamples); 805 } 806 else 807 { 808 GenerateRays(DETERMINISTIC_GVS ? numSamples : numSamples / 16, *mDistribution, simpleRays, sInvalidSamples); 809 } 802 810 803 811 generationTimer.Exit(); … … 814 822 const bool pruneInvalidRays = false; 815 823 //const bool pruneInvalidRays = true; 824 816 825 CastRays(simpleRays, vssRays, castDoubleRays, pruneInvalidRays); 817 826 } … … 1432 1441 mGvsStats.mRandomSamples = 0; 1433 1442 mGvsStats.mGvsSamples = 0; 1434 1443 mUseProbablyVisibleSampling = false; 1435 1444 //renderer->mPvsStat.currentPass = 0; 1445 1436 1446 mPass = 0; 1437 1447 … … 1471 1481 newRandomSamples = CastInitialSamples(mInitialSamples); 1472 1482 1483 //if (!mUseProbablyVisibleSampling && !mOnlyRandomSampling) 1473 1484 if (!mOnlyRandomSampling) 1474 1485 newGvsSamples = ProcessQueue(); … … 1500 1511 ++ mPass; 1501 1512 mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution; 1513 1514 if (mGvsStats.mPassContribution < 2000) 1515 mUseProbablyVisibleSampling = true; 1516 1517 if (mUseProbablyVisibleSampling) 1518 PrepareProbablyVisibleSampling(); 1502 1519 1503 1520 … … 1943 1960 1944 1961 1945 } 1962 void GvsPreprocessor::PrepareProbablyVisibleSampling() 1963 { 1964 1965 // warning: using mailing! 1966 Intersectable::NewMail(); 1967 1968 mProbablyVisibleTriangles.clear(); 1969 CollectProbablyVisibleTriangles(mProbablyVisibleTriangles); 1970 } 1971 1972 1973 void GvsPreprocessor::CollectProbablyVisibleTriangles(ObjectContainer &triangles) 1974 { 1975 ObjectPvsIterator pit = mCurrentViewCell->GetPvs().GetIterator(); 1976 1977 static ObjectContainer tmpTriangles; 1978 1979 while (pit.HasMoreEntries()) 1980 { 1981 tmpTriangles.clear(); 1982 1983 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 1984 mKdTree->CollectObjectsWithDublicates(kdObj->GetItem(), tmpTriangles); 1985 1986 ObjectContainer::const_iterator oit, oit_end = tmpTriangles.end(); 1987 1988 for (oit = tmpTriangles.begin(); oit != oit_end; ++ oit) 1989 { 1990 TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 1991 1992 // find objects which are not yet accounted for yet contained in kd pvs objects 1993 if (!triObj->Mailed() && (triObj->mCounter < ACCOUNTED_OBJECT)) 1994 { 1995 triObj->Mail(); 1996 triangles.push_back(triObj); 1997 } 1998 } 1999 } 2000 } 2001 2002 2003 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r2731 r2735 281 281 SimpleRayContainer &simpleRays); 282 282 283 /** Collects triangles which are probably visible. Warning: returns 284 only unmailed objects. 285 */ 286 void CollectProbablyVisibleTriangles(ObjectContainer &triangles); 287 288 void PrepareProbablyVisibleSampling(); 289 290 283 291 ////////////////////// 284 292 … … 323 331 324 332 Vector3 mCurrentViewPoint; 333 334 /// container for probably visible triangles 335 ObjectContainer mProbablyVisibleTriangles; 336 337 bool mUseProbablyVisibleSampling; 325 338 }; 326 339 -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r2728 r2735 1 2 1 #include "SamplingStrategy.h" 3 2 #include "Ray.h" … … 18 17 #define USE_HALTON 1 19 18 19 20 20 namespace GtpVisibilityPreprocessor { 21 21 … … 27 27 #endif 28 28 29 //HaltonSequence SamplingStrategy::sHalton;30 31 29 HaltonSequence ObjectBasedDistribution::sHalton; 32 30 HaltonSequence MixtureDistribution::sHalton; … … 39 37 HaltonSequence ViewCellBasedDistribution::sHalton; 40 38 HaltonSequence ViewCellBorderBasedDistribution::sHalton; 39 HaltonSequence ProbablyVisibleDistribution::sHalton; 40 41 41 42 42 43 SamplingStrategy::SamplingStrategy(Preprocessor &preprocessor): … … 575 576 { 576 577 #ifdef USE_PERFTIMER 577 const floatvcTime = viewCellCastTimer.TotalTime();578 const floatpvsTime = pvsTimer.TotalTime();579 const floathaltonTime = haltonTimer.TotalTime();578 const double vcTime = viewCellCastTimer.TotalTime(); 579 const double pvsTime = pvsTimer.TotalTime(); 580 const double haltonTime = haltonTimer.TotalTime(); 580 581 581 582 cout << "view cell cast time: " << vcTime << " s" << endl; … … 881 882 882 883 883 } 884 885 884 bool ProbablyVisibleDistribution::GenerateSample(SimpleRay &ray) 885 { 886 static Vector3 origin; 887 static Vector3 direction; 888 static Vector3 point; 889 static Vector3 normal; 890 891 float r[2]; 892 sHalton.GetNext(2, r); 893 894 r[0] *= (float)(*mObjects).size() - 1.0f; 895 const int i = (int)r[0]; 896 897 Intersectable *obj = (*mObjects)[i]; 898 899 obj->GetRandomSurfacePoint(point, normal); 900 901 // get point on view cell surface 902 if (1) 903 origin = mViewCell->GetBox().GetRandomSurfacePoint(); 904 else 905 origin = mViewCell->GetBox().GetUniformRandomSurfacePoint(); 906 907 direction = point - origin; 908 909 const float c = Magnitude(direction); 910 911 if (c <= Limits::Small) 912 return false; 913 914 ray = SimpleRay(origin, direction, PROBABLY_VISIBLE_DISTRIBUTION, 1.0f); 915 916 return true; 917 } 918 919 } 920 921 -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
r2728 r2735 7 7 #include "common.h" 8 8 #include "Halton.h" 9 #include "Containers.h" 9 10 10 11 … … 52 53 FILTER_BASED_DISTRIBUTION, 53 54 DIFFERENCE_SAMPLING_BASED_DISTRIBUTION, 55 PROBABLY_VISIBLE_DISTRIBUTION 54 56 }; 55 57 … … 246 248 }; 247 249 250 251 class MixtureDistribution: public SamplingStrategy 252 { 253 public: 254 255 // container for the distributions 256 std::vector<SamplingStrategy *> mDistributions; 257 258 MixtureDistribution(Preprocessor &preprocessor): 259 SamplingStrategy(preprocessor) 260 { 261 } 262 263 // has to called before first usage 264 void Init(); 265 266 // equalize distribution contributions 267 void 268 Reset(); 269 270 // add contributions of the sample to the strategies 271 void ComputeContributions(VssRayContainer &vssRays); 272 273 // update distributions with new rays 274 // warning: some rays can get deleted (if maintained internally by the 275 // particular distribution)! 276 void UpdateDistributions(VssRayContainer &vssRays); 277 278 void 279 UpdateRatios(); 280 281 // construct distribution mixture from a string describing the required distributions 282 bool 283 Construct(char *str); 284 285 virtual bool RequiresRays() { 286 for (int i=0; i < (int)mDistributions.size(); i++) 287 if (mDistributions[i]->RequiresRays()) 288 return true; 289 return false; 290 } 291 292 virtual int GenerateSamples(int number, SimpleRayContainer &rays, int &invalidSamples); 293 294 private: 295 296 // Generate a new sample according to a mixture distribution 297 virtual bool GenerateSample(SimpleRay &ray); 298 299 // halton sequence generator for deciding between distributions 300 static HaltonSequence sHalton; 301 }; 302 303 248 304 class ViewCellBasedDistribution: public SamplingStrategy 249 305 { … … 268 324 269 325 270 class MixtureDistribution: public SamplingStrategy271 {272 public:273 274 // container for the distributions275 std::vector<SamplingStrategy *> mDistributions;276 277 MixtureDistribution(Preprocessor &preprocessor):278 SamplingStrategy(preprocessor)279 {280 }281 282 // has to called before first usage283 void Init();284 285 // equalize distribution contributions286 void287 Reset();288 289 // add contributions of the sample to the strategies290 void ComputeContributions(VssRayContainer &vssRays);291 292 // update distributions with new rays293 // warning: some rays can get deleted (if maintained internally by the294 // particular distribution)!295 void UpdateDistributions(VssRayContainer &vssRays);296 297 void298 UpdateRatios();299 300 // construct distribution mixture from a string describing the required distributions301 bool302 Construct(char *str);303 304 virtual bool RequiresRays() {305 for (int i=0; i < (int)mDistributions.size(); i++)306 if (mDistributions[i]->RequiresRays())307 return true;308 return false;309 }310 311 virtual int GenerateSamples(int number, SimpleRayContainer &rays, int &invalidSamples);312 313 private:314 315 // Generate a new sample according to a mixture distribution316 virtual bool GenerateSample(SimpleRay &ray);317 318 // halton sequence generator for deciding between distributions319 static HaltonSequence sHalton;320 };321 322 326 class ViewCellBorderBasedDistribution: public SamplingStrategy 323 327 { … … 343 347 344 348 349 class ProbablyVisibleDistribution: public SamplingStrategy 350 { 351 public: 352 ProbablyVisibleDistribution(Preprocessor &preprocessor, 353 ViewCell *viewCell, 354 ObjectContainer *objects) 355 : SamplingStrategy(preprocessor), mViewCell(viewCell), mObjects(objects) 356 { 357 mType = PROBABLY_VISIBLE_DISTRIBUTION; 358 } 359 360 void SetViewCell(ViewCell *vc) { mViewCell = vc; } 361 362 private: 363 364 virtual bool GenerateSample(SimpleRay &ray); 365 366 ViewCell *mViewCell; 367 ObjectContainer *mObjects; 368 369 static HaltonSequence sHalton; 370 }; 371 372 345 373 }; 346 374 -
GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor05.vcproj
r2729 r2735 159 159 LinkIncremental="1" 160 160 AdditionalLibraryDirectories=""$(QTDIR)\lib";..\src\GL;"..\lib05\$(ConfigurationName)";..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;"..\MultiLevelRayTracing\RTScene\$(ConfigurationName)";"..\MultiLevelRayTracing\RTWorld\$(ConfigurationName)";"QtInterface\$(ConfigurationName)";"..\..\..\..\..\..\NonGTP\Xerces\xerces-c_2_8_0\lib";"$(CG_LIB_PATH)"" 161 GenerateDebugInformation=" false"161 GenerateDebugInformation="true" 162 162 SubSystem="1" 163 163 LargeAddressAware="2"
Note: See TracChangeset
for help on using the changeset viewer.