Changeset 556
- Timestamp:
- 01/19/06 15:30:44 (18 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r544 r556 49 49 GlRenderer::~GlRenderer() 50 50 { 51 cerr<<"gl renderer destructor..\n"; 52 if (sCgFragmentProgram) 51 53 cgDestroyProgram(sCgFragmentProgram); 54 if (sCgContext) 52 55 cgDestroyContext(sCgContext); 56 cerr<<"done."<<endl; 53 57 } 54 58 … … 283 287 &pixelCount); 284 288 285 pErrorPixels = ( 100.f*pixelCount)/(GetWidth()*GetHeight());289 pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight()); 286 290 } 287 291 … … 343 347 errorPixels++; 344 348 } 345 pErrorPixels = ( 100.f*errorPixels)/(im1.height()*im1.width());349 pErrorPixels = ((float)errorPixels)/(im1.height()*im1.width()); 346 350 } 347 351 … … 466 470 } 467 471 } 468 472 473 glFinish(); 469 474 doneCurrent(); 470 475 471 476 cout<<endl<<flush; 472 mRenderingFinished.wakeAll();477 // mRenderingFinished.wakeAll(); 473 478 } 474 479 … … 940 945 void GlRendererBuffer::InitGL() 941 946 { 942 GlRenderer::InitGL(); 947 makeCurrent(); 948 GlRenderer::InitGL(); 949 #if 0 943 950 // initialise dual depth buffer textures 944 951 glGenTextures(1, &frontDepthMap); … … 980 987 } 981 988 982 sCgFragmentProgram = cgCreateProgramFromFile(sCgContext, 989 990 sCgFragmentProgram = cgCreateProgramFromFile(sCgContext, 983 991 CG_SOURCE, "../src/dual_depth.cg", 984 992 sCgFragmentProfile, … … 991 999 cgGLLoadProgram(sCgFragmentProgram); 992 1000 cgGLBindProgram(sCgFragmentProgram); 993 994 Debug << "---- PROGRAM BEGIN ----\n" << 1001 1002 Debug << "---- PROGRAM BEGIN ----\n" << 995 1003 cgGetProgramString(sCgFragmentProgram, CG_COMPILED_PROGRAM) << "---- PROGRAM END ----\n"; 1004 1005 #endif 1006 doneCurrent(); 996 1007 } 997 1008 … … 1071 1082 GlDebuggerWidget::~GlDebuggerWidget() 1072 1083 { 1073 1074 1075 1076 DEL_PTR(mRenderBuffer);1084 mRenderBuffer->releaseFromDynamicTexture(); 1085 glDeleteTextures(1, &dynamicTexture); 1086 1087 DEL_PTR(mRenderBuffer); 1077 1088 } 1078 1089 -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h
r540 r556 122 122 QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells, tree) { 123 123 124 mPvsStatFrames = 10000;124 mPvsStatFrames = 5000; 125 125 mPvsErrorBuffer.resize(mPvsStatFrames); 126 126 ClearErrorBuffer(); 127 127 128 makeCurrent();129 InitGL();130 doneCurrent();128 // makeCurrent(); 129 // InitGL(); 130 // doneCurrent(); 131 131 132 132 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Intersectable.h
r497 r556 75 75 VssRayContainer &rays 76 76 ) {return 0;} 77 77 78 static bool GreaterCounter(const Intersectable *a, 79 const Intersectable *b) { 80 return a->mCounter > b->mCounter; 81 } 78 82 }; 79 83 -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp
r535 r556 922 922 // kd tree PVS 923 923 float contribution; 924 if (leaf->mKdPvs.AddSample(node, contribution))924 if (leaf->mKdPvs.AddSample(node, 1.0f, contribution)) 925 925 totalPvsSize++; 926 926 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Makefile
r549 r556 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.0) on: po 16. I 20:32:4520063 # Generated by qmake (2.00a) (Qt 4.1.0) on: ?t 19. I 11:57:31 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app … … 7 7 ############################################################################# 8 8 9 first: release10 install: release-install11 uninstall: release-uninstall9 first: debug 10 install: debug-install 11 uninstall: debug-uninstall 12 12 MAKEFILE = Makefile 13 13 QMAKE = qmake … … 27 27 MKDIR = mkdir 28 28 SUBTARGETS = \ 29 release\30 debug29 debug \ 30 release 31 31 32 debug: $(MAKEFILE).Debug FORCE 33 $(MAKE) -f $(MAKEFILE).Debug 34 debug-make_default: $(MAKEFILE).Debug FORCE 35 $(MAKE) -f $(MAKEFILE).Debug 36 debug-make_first: $(MAKEFILE).Debug FORCE 37 $(MAKE) -f $(MAKEFILE).Debug first 38 debug-all: $(MAKEFILE).Debug FORCE 39 $(MAKE) -f $(MAKEFILE).Debug all 40 debug-clean: $(MAKEFILE).Debug FORCE 41 $(MAKE) -f $(MAKEFILE).Debug clean 42 debug-distclean: $(MAKEFILE).Debug FORCE 43 $(MAKE) -f $(MAKEFILE).Debug distclean 44 debug-install: $(MAKEFILE).Debug FORCE 45 $(MAKE) -f $(MAKEFILE).Debug install 46 debug-uninstall: $(MAKEFILE).Debug FORCE 47 $(MAKE) -f $(MAKEFILE).Debug uninstall 32 48 release: $(MAKEFILE).Release FORCE 33 49 $(MAKE) -f $(MAKEFILE).Release … … 46 62 release-uninstall: $(MAKEFILE).Release FORCE 47 63 $(MAKE) -f $(MAKEFILE).Release uninstall 48 debug: $(MAKEFILE).Debug FORCE49 $(MAKE) -f $(MAKEFILE).Debug50 debug-make_default: $(MAKEFILE).Debug FORCE51 $(MAKE) -f $(MAKEFILE).Debug52 debug-make_first: $(MAKEFILE).Debug FORCE53 $(MAKE) -f $(MAKEFILE).Debug first54 debug-all: $(MAKEFILE).Debug FORCE55 $(MAKE) -f $(MAKEFILE).Debug all56 debug-clean: $(MAKEFILE).Debug FORCE57 $(MAKE) -f $(MAKEFILE).Debug clean58 debug-distclean: $(MAKEFILE).Debug FORCE59 $(MAKE) -f $(MAKEFILE).Debug distclean60 debug-install: $(MAKEFILE).Debug FORCE61 $(MAKE) -f $(MAKEFILE).Debug install62 debug-uninstall: $(MAKEFILE).Debug FORCE63 $(MAKE) -f $(MAKEFILE).Debug uninstall64 64 65 65 Makefile: preprocessor.pro D:/Qt/4.1.0/mkspecs/win32-msvc.net\qmake.conf D:/Qt/4.1.0/mkspecs/qconfig.pri \ … … 68 68 D:\Qt\4.1.0\mkspecs\features\default_pre.prf \ 69 69 D:\Qt\4.1.0\mkspecs\features\win32\default_pre.prf \ 70 D:\Qt\4.1.0\mkspecs\features\ release.prf \70 D:\Qt\4.1.0\mkspecs\features\debug.prf \ 71 71 D:\Qt\4.1.0\mkspecs\features\debug_and_release.prf \ 72 72 D:\Qt\4.1.0\mkspecs\features\default_post.prf \ … … 89 89 D:\Qt\4.1.0\mkspecs\features\default_pre.prf: 90 90 D:\Qt\4.1.0\mkspecs\features\win32\default_pre.prf: 91 D:\Qt\4.1.0\mkspecs\features\ release.prf:91 D:\Qt\4.1.0\mkspecs\features\debug.prf: 92 92 D:\Qt\4.1.0\mkspecs\features\debug_and_release.prf: 93 93 D:\Qt\4.1.0\mkspecs\features\default_post.prf: … … 109 109 qmake_all: FORCE 110 110 111 make_default: release-make_default debug-make_default FORCE112 make_first: release-make_first debug-make_first FORCE113 all: release-all debug-all FORCE114 clean: release-clean debug-clean FORCE111 make_default: debug-make_default release-make_default FORCE 112 make_first: debug-make_first release-make_first FORCE 113 all: debug-all release-all FORCE 114 clean: debug-clean release-clean FORCE 115 115 -$(DEL_FILE) preprocessor.exp 116 distclean: release-distclean debug-distclean FORCE 116 -$(DEL_FILE) preprocessor.pdb 117 -$(DEL_FILE) preprocessor.ilk 118 -$(DEL_FILE) vc*.pdb 119 -$(DEL_FILE) vc*.idb 120 distclean: debug-distclean release-distclean FORCE 117 121 -$(DEL_FILE) Makefile 118 122 123 debug-mocclean: $(MAKEFILE).Debug 124 $(MAKE) -f $(MAKEFILE).Debug mocclean 119 125 release-mocclean: $(MAKEFILE).Release 120 126 $(MAKE) -f $(MAKEFILE).Release mocclean 121 debug-mocclean: $(MAKEFILE).Debug 122 $(MAKE) -f $(MAKEFILE).Debug mocclean 123 mocclean: release-mocclean debug-mocclean 127 mocclean: debug-mocclean release-mocclean 124 128 129 debug-mocables: $(MAKEFILE).Debug 130 $(MAKE) -f $(MAKEFILE).Debug mocables 125 131 release-mocables: $(MAKEFILE).Release 126 132 $(MAKE) -f $(MAKEFILE).Release mocables 127 debug-mocables: $(MAKEFILE).Debug 128 $(MAKE) -f $(MAKEFILE).Debug mocables 129 mocables: release-mocables debug-mocables 133 mocables: debug-mocables release-mocables 130 134 FORCE: 131 135 136 $(MAKEFILE).Debug: Makefile 132 137 $(MAKEFILE).Release: Makefile 133 $(MAKEFILE).Debug: Makefile -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r540 r556 33 33 Preprocessor::~Preprocessor() 34 34 { 35 cerr<<"Deleting view cells manager...\n"; 35 36 DEL_PTR(mViewCellsManager); 37 cerr<<"done.\n"; 38 cerr<<"Deleting bsp tree...\n"; 36 39 DEL_PTR(mBspTree); 40 cerr<<"done.\n"; 41 cerr<<"Deleting kd tree...\n"; 37 42 DEL_PTR(mKdTree); 43 cerr<<"done.\n"; 44 cerr<<"Deleting vspkd tree...\n"; 38 45 DEL_PTR(mVspKdTree); 46 cerr<<"done.\n"; 47 cerr<<"Deleting vspbsp tree...\n"; 39 48 DEL_PTR(mVspBspTree); 49 cerr<<"done.\n"; 40 50 } 41 51 … … 258 268 mViewCellsFilename = buf; 259 269 } 270 260 271 if (mUseGlRenderer || mUseGlDebugger) 261 272 { … … 263 274 // renderer must be initialised 264 275 renderer = new GlRendererBuffer(1024, 768, mSceneGraph, mViewCellsManager, mKdTree); 265 renderer->makeCurrent();276 // renderer->makeCurrent(); 266 277 } 267 278 -
trunk/VUT/GtpVisibilityPreprocessor/src/PreprocessorThread.cpp
r492 r556 13 13 { 14 14 mPreprocessor = p; 15 connect(this, SIGNAL(finished()), qApp, SLOT(closeAllWindows(void))); 15 16 } 16 17 … … 21 22 if (1) { 22 23 mPreprocessor->ComputeVisibility(); 23 24 // mPreprocessor->ExportPreprocessedData("scene.vis"); 24 25 } 25 26 26 27 Camera camera; 28 27 29 if (0) { 28 30 camera.LookAtBox(mPreprocessor->mKdTree->GetBox()); … … 43 45 } 44 46 45 QApplication::quit(); 47 48 cerr<<"Preprocessor main finished...\n"; 46 49 47 50 } 51 52 PreprocessorThread::~PreprocessorThread() 53 { 54 cerr<<"Preprocessor thread destructor...\n"; 55 } -
trunk/VUT/GtpVisibilityPreprocessor/src/PreprocessorThread.h
r492 r556 13 13 public: 14 14 PreprocessorThread(Preprocessor *p, QObject *parent = 0); 15 ~PreprocessorThread() {}15 ~PreprocessorThread(); 16 16 17 17 void Main(); -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h
r492 r556 25 25 template<typename T> 26 26 struct PvsData { 27 int mVisibleSamples; 27 // int mVisibleSamples; 28 // sum of probability density of visible sample rays 29 float mSumPdf; 28 30 PvsData<T>() {} 29 PvsData<T>(const int samples): mVisibleSamples(samples) {} 31 PvsData<T>(const float sumPdf): 32 mSumPdf(sumPdf) {} 33 34 // $$JB in order to return meaningfull values 35 // it assumes that the sum pdf has been normalized somehow!!! 36 float GetVisibility() { return mSumPdf; } 30 37 }; 31 38 … … 46 53 int GetSize() const {return (int)mEntries.size();} 47 54 bool Empty() const {return mEntries.empty();} 55 56 /** Normalize the visibility of entries in order to get comparable 57 results */ 58 59 void NormalizeMaximum(); 48 60 49 61 /** Merges pvs of a and pvs of b into this pvs. … … 61 73 PvsData<T> *Find(T sample); 62 74 63 bool GetSampleContribution(T sample, float &contribution);75 bool GetSampleContribution(T sample, const float pdf, float &contribution); 64 76 65 77 /** Adds sample to PVS. … … 67 79 @returns true if sample was not already in PVS. 68 80 */ 69 bool AddSample(T sample, float &contribution);81 bool AddSample(T sample, const float pdf, float &contribution); 70 82 71 83 /** Adds sample to PVS. 72 84 @returns contribution of sample (0 or 1) 73 85 */ 74 int AddSample(T sample);86 float AddSample(T sample, const float pdf); 75 87 76 88 /** Adds one pvs to another one. … … 94 106 @param visibleSampels number of references to be removed 95 107 */ 96 bool RemoveSample(T sample, const int visibleSamples);108 bool RemoveSample(T sample, const float pdf); 97 109 98 110 /// Map of PVS entries … … 130 142 131 143 if (data) 132 data->m VisibleSamples += (*it).second.mVisibleSamples;144 data->mSumPdf += (*it).second.mSumPdf; 133 145 else 134 146 mEntries.insert(*it); … … 159 171 160 172 template <typename T> 161 int162 Pvs<T>::AddSample(T sample )173 float 174 Pvs<T>::AddSample(T sample, const float pdf) 163 175 { 164 176 PvsData<T> *data = Find(sample); 165 177 166 178 if (data) { 167 return ++data->mVisibleSamples; 179 data->mSumPdf+=pdf; 180 return data->mSumPdf; 168 181 } 169 182 else { 170 mEntries[sample] = PvsData<T>( 1);171 return 1;183 mEntries[sample] = PvsData<T>(pdf); 184 return pdf; 172 185 } 173 186 } … … 175 188 template <typename T> 176 189 bool 177 Pvs<T>::AddSample(T sample, float &contribution) 190 Pvs<T>::AddSample(T sample, 191 const float pdf, 192 float &contribution) 178 193 { 179 194 PvsData<T> *data = Find(sample); 180 195 181 196 if (data) { 182 data->m VisibleSamples++;183 contribution = 1.0f/data->mVisibleSamples;197 data->mSumPdf+=pdf; 198 contribution = pdf/data->mSumPdf; 184 199 return false; 185 200 } 186 201 else { 187 mEntries[sample] = PvsData<T>( 1);202 mEntries[sample] = PvsData<T>(pdf); 188 203 contribution = 1.0f; 189 204 return true; … … 193 208 template <typename T> 194 209 bool 195 Pvs<T>::GetSampleContribution(T sample, float &contribution) 210 Pvs<T>::GetSampleContribution(T sample, 211 const float pdf, 212 float &contribution) 196 213 { 197 214 PvsData<T> *data = Find(sample); 198 215 199 216 if (data) { 200 contribution = 1.0f/(data->mVisibleSamples + 1);217 contribution = pdf/(data->mSumPdf + pdf); 201 218 return false; 202 219 } … … 208 225 209 226 template <typename T> 210 bool Pvs<T>::RemoveSample(T sample, const int visibleSamples) 211 { 212 std::map<T, PvsData<T>, LtSample<T> >:: 213 iterator it = mEntries.find(sample); 214 215 if (it == mEntries.end()) 216 return false; 217 218 PvsData<T> *data = &(*it).second; 219 220 data->mVisibleSamples -= visibleSamples; 221 if (data->mVisibleSamples <= 0) 222 mEntries.erase(it); 223 224 return true; 227 bool Pvs<T>::RemoveSample(T sample, 228 const float pdf) 229 { 230 std::map<T, PvsData<T>, LtSample<T> >:: 231 iterator it = mEntries.find(sample); 232 233 if (it == mEntries.end()) 234 return false; 235 236 PvsData<T> *data = &(*it).second; 237 238 data->mSumPdf -= pdf; 239 if (data->mSumPdf <= 0.0f) 240 mEntries.erase(it); 241 242 return true; 225 243 } 226 244 … … 228 246 int Pvs<T>::AddPvs(const Pvs<T> &pvs) 229 247 { 230 231 232 233 234 235 236 AddSample((*it).first, contri);237 238 248 std::map<T, PvsData<T>, LtSample<T> >:: 249 const_iterator it, it_end = pvs.mEntries.end(); 250 251 float contri; 252 // output PVS of view cell 253 for (it = pvs.mEntries.begin(); it != it_end; ++ it) 254 AddSample((*it).first, (*it).second.mSumPdf, contri); 255 256 return GetSize(); 239 257 } 240 258 … … 242 260 int Pvs<T>::SubtractPvs(const Pvs<T> &pvs) 243 261 { 244 245 246 247 248 249 RemoveSample((*it).first, (*it).second.mVisibleSamples);250 251 262 std::map<T, PvsData<T>, LtSample<T> >:: 263 const_iterator it, it_end = pvs.mEntries.end(); 264 265 // output PVS of view cell 266 for (it = pvs.mEntries.begin(); it != it_end; ++ it) 267 RemoveSample((*it).first, (*it).second.mSumPdf); 268 269 return GetSize(); 252 270 } 253 271 … … 262 280 entries.push_back((*it)->first); 263 281 } 282 283 template <typename T> 284 void Pvs<T>::NormalizeMaximum() 285 { 286 std::map<T, PvsData<T>, LtSample<T> >:: 287 const_iterator it, it_end = mEntries.end(); 288 289 float maxPdfSum = -1.0f; 290 291 // output PVS of view cell 292 for (it = mEntries.begin(); it != it_end; ++ it) { 293 float sum = (*it)->second.sumPdf; 294 if (sum > maxSum) 295 maxSum = sum; 296 } 297 298 maxSum = 1.0f/maxSum; 299 300 for (it = mEntries.begin(); it != it_end; ++ it) { 301 (*it)->second.sumPdf *= maxSum; 302 } 303 304 } 305 264 306 265 307 /** Class instantiating the Pvs template for kd tree nodes. -
trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h
r537 r556 304 304 Vector3 mOrigin; 305 305 Vector3 mDirection; 306 float mP robability;306 float mPdf; 307 307 308 308 SimpleRay() {} 309 309 SimpleRay(const Vector3 &o, const Vector3 &d, const float p=1.0f): 310 mOrigin(o), mDirection(d), mP robability(p) {}310 mOrigin(o), mDirection(d), mPdf(p) {} 311 311 }; 312 312 … … 315 315 public: 316 316 317 float mSumP robabilities;318 319 SimpleRayContainer():vector<SimpleRay>(), mSumP robabilities(0.0f) {}320 321 void NormalizeP robabilities() {317 float mSumPdf; 318 319 SimpleRayContainer():vector<SimpleRay>(), mSumPdf(0.0f) {} 320 321 void NormalizePdf() { 322 322 iterator it = begin(); 323 float c = 1.0f/mSumP robabilities;323 float c = 1.0f/mSumPdf; 324 324 for (; it != end(); it++) 325 (*it).mP robability*=c;325 (*it).mPdf*=c; 326 326 } 327 327 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r549 r556 85 85 if (!mDetectEmptyViewSpace) 86 86 ray.mFlags &= ~Ray::CULL_BACKFACES; 87 else 88 ray.mFlags |= Ray::CULL_BACKFACES; 89 87 90 88 91 // cast ray to KD tree to find intersection with other objects … … 113 116 if (!mDetectEmptyViewSpace) 114 117 ray.mFlags &= ~Ray::CULL_BACKFACES; 118 else 119 ray.mFlags |= Ray::CULL_BACKFACES; 115 120 116 121 if (mKdTree->CastRay(ray)) { … … 130 135 // cast again to ensure that there is no objectA 131 136 SetupRay(ray, pointB, direction); 137 ray.mFlags |= Ray::CULL_BACKFACES; 132 138 if (mKdTree->CastRay(ray)) { 133 139 objectA = ray.intersections[0].mObject; … … 315 321 // exporter->ExportKdTree(*mKdTree); 316 322 exporter->SetFilled(); 317 // temporarily do not export the scene318 if ( 0)323 // $$JB temporarily do not export the scene 324 if (1) 319 325 exporter->ExportScene(mSceneGraph->mRoot); 320 326 exporter->SetWireframe(); … … 459 465 // renderer->mRenderingFinished.wait(&mutex); 460 466 // mutex.unlock(); 467 461 468 renderer->EvalPvsStat(); 462 469 mStats << … … 470 477 RssPreprocessor::ComputeVisibility() 471 478 { 479 480 if (renderer) 481 renderer->InitGL(); 472 482 473 483 // connect(this, SIGNAL(EvalPvsStat()), renderer, SLOT(EvalPvsStat()) ); … … 698 708 Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 699 709 rays.push_back(SimpleRay(viewpoint, direction, 1.0f)); 700 rays.mSumP robabilities+=1.0f;710 rays.mSumPdf += 1.0f; 701 711 } 702 712 } else { … … 704 714 } 705 715 706 rays.NormalizeP robabilities();716 rays.NormalizePdf(); 707 717 708 718 for (int i=0; i < rays.size(); i++) 709 CastRay(rays[i].mOrigin, rays[i].mDirection, rays[i].mP robability, vssRays);719 CastRay(rays[i].mOrigin, rays[i].mDirection, rays[i].mPdf, vssRays); 710 720 711 721 … … 802 812 if (mUseViewcells) { 803 813 804 805 //-- render simulation after merge 806 cout << "\nevaluating bsp view cells render time after merge ... "; 807 808 mRenderSimulator->RenderScene(); 809 SimulationStatistics ss; 810 mRenderSimulator->GetStatistics(ss); 811 812 cout << " finished" << endl; 813 cout << ss << endl; 814 Debug << ss << endl; 815 816 } 817 814 815 //-- render simulation after merge 816 cout << "\nevaluating bsp view cells render time after merge ... "; 817 818 mRenderSimulator->RenderScene(); 819 SimulationStatistics ss; 820 mRenderSimulator->GetStatistics(ss); 821 822 cout << " finished" << endl; 823 cout << ss << endl; 824 Debug << ss << endl; 825 826 } 827 828 cerr<<"Deleting RSS tree...\n"; 818 829 delete rssTree; 830 cerr<<"Done.\n"; 831 819 832 820 833 return true; -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp
r551 r556 1030 1030 // if ( (int)(leaf->rays.size()) < termMinCost) 1031 1031 // stat.minCostNodes++; 1032 if ( leaf->GetPvsSize() < termMinPvs)1032 if ( leaf->GetPvsSize() <= termMinPvs) 1033 1033 stat.minPvsNodes++; 1034 1034 1035 if ( leaf->GetPvsSize() < termMinRays)1035 if ( leaf->GetPvsSize() <= termMinRays) 1036 1036 stat.minRaysNodes++; 1037 1037 … … 1051 1051 RssTree::TerminationCriteriaSatisfied(RssTreeLeaf *leaf) 1052 1052 { 1053 return ( (leaf->GetPvsSize() < termMinPvs) ||1054 (leaf->rays.size() < termMinRays) ||1053 return ( (leaf->GetPvsSize() <= termMinPvs) || 1054 (leaf->rays.size() <= termMinRays) || 1055 1055 // (leaf->GetAvgRayContribution() > termMaxRayContribution ) || 1056 1056 (leaf->depth >= termMaxDepth) || … … 2081 2081 ri++) { 2082 2082 Intersectable *object = (*ri).GetObject(); 2083 if (object && !object->Mailed()) { 2084 object->Mail(); 2085 pvs.push_back(object); 2086 if (exporter) 2087 exporter->ExportIntersectable(object); 2088 } 2089 } 2090 2083 if (object) { 2084 if (!object->Mailed()) { 2085 object->Mail(); 2086 object->mCounter = 1; 2087 pvs.push_back(object); 2088 if (exporter) 2089 exporter->ExportIntersectable(object); 2090 } else { 2091 object->mCounter++; 2092 } 2093 } 2094 } 2095 // sort objects based on their mCounter 2096 sort(pvs.begin(), pvs.end(), Intersectable::GreaterCounter); 2097 2091 2098 float extendedConvexCombinationProb = 0.0f; //0.7f 2092 float silhouetteCheckPercentage = 0. 0f; //0.5f2099 float silhouetteCheckPercentage = 0.5f; //0.5f 2093 2100 for (int i=0; generated < numberOfRays && i < numberOfTries; i++) { 2094 2101 bool useExtendedConvexCombination = ((nrays >= 2) && (Random(1.0f) < … … 2179 2186 oi++) { 2180 2187 Intersectable *object = *oi; 2181 2182 2188 if ( object->CastRay(traversalRay) ) { 2183 2189 intersects = true; … … 2197 2203 2198 2204 // cout<<"desired="<<numberOfRays<<" tries="<<i<<endl; 2199 // assign p robabilitites to the generated rays2200 float p = (box.GetVolume()*dirBox.GetVolume())/ generated;2205 // assign pdfs to the generated rays 2206 float p = (box.GetVolume()*dirBox.GetVolume())/i; 2201 2207 for (i=startIndex; i < rays.size(); i++) { 2202 rays[i].mP robability= p;2203 rays.mSumP robabilities+= p;2208 rays[i].mPdf = p; 2209 rays.mSumPdf += p; 2204 2210 } 2205 2211 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r551 r556 2470 2470 float relContribution; 2471 2471 if (!ray->intersections.empty()) 2472 contribution += vc->GetPvs().AddSample(ray->intersections[0].mObject, relContribution); 2472 contribution += vc->GetPvs().AddSample(ray->intersections[0].mObject, 2473 1.0f, 2474 relContribution); 2473 2475 2474 2476 if (ray->sourceObject.mObject) 2475 contribution += vc->GetPvs().AddSample(ray->sourceObject.mObject, relContribution); 2476 2477 contribution += vc->GetPvs().AddSample(ray->sourceObject.mObject, 2478 1.0f, 2479 relContribution); 2480 2477 2481 if (contribution) 2478 2482 { -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r555 r556 458 458 bool added = 459 459 viewcell->GetPvs().AddSample(ray.mTerminationObject, 460 contribution 461 ); 460 ray.mPdf, 461 contribution 462 ); 462 463 if (added) 463 464 ray.mPvsContribution++; … … 473 474 float contribution; 474 475 if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 475 contribution 476 )) 477 ray.mPvsContribution++; 476 ray.mPdf, 477 contribution 478 )) 479 ray.mPvsContribution++; 478 480 ray.mRelativePvsContribution += contribution; 479 481 } 480 482 481 483 for (it = viewcells.begin(); it != viewcells.end(); ++it) { 482 483 484 viewcell->GetPvs().AddSample(ray.mTerminationObject);484 ViewCell *viewcell = *it; 485 // if ray not outside of view space 486 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 485 487 } 486 488 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r555 r556 300 300 virtual void ExportColor(Exporter *exporter, ViewCell *vc) const = 0; 301 301 302 302 303 virtual float GetViewSpaceVolume() { 304 return mViewSpaceBox.GetVolume()*(2.0f*sqr(M_PI)); 305 } 303 306 /** Creates meshes from the view cells. 304 307 */ -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParser.cpp
r508 r556 197 197 198 198 ObjectContainer::iterator oit = 199 200 199 lower_bound(mObjects->begin(), mObjects->end(), &dummyInst, ilt); 200 201 201 Intersectable *obj = *oit; 202 202 203 203 if (obj->GetId() == objId) 204 204 { 205 viewCell->GetPvs().AddSample(obj); 205 // $$JB we should store a float a per object which corresponds 206 // to sumof pdfs, i.e. its relative visibility 207 // temporarily set to 1.0f 208 viewCell->GetPvs().AddSample(obj, 1.0f); 206 209 } 207 210 else -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r555 r556 493 493 494 494 //-- update pvs 495 int conSamp = 0, sampCon = 0; 496 AddToPvs(leaf, *tData.mRays, conSamp, sampCon); 495 int conSamp = 0; 496 float sampCon = 0.0f; 497 AddToPvs(leaf, *tData.mRays, sampCon, conSamp); 497 498 498 499 mStat.contributingSamples += conSamp; … … 660 661 void VspBspTree::AddToPvs(BspLeaf *leaf, 661 662 const RayInfoContainer &rays, 662 int &sampleContributions,663 float &sampleContributions, 663 664 int &contributingSamples) 664 665 { 665 sampleContributions = 0; 666 contributingSamples = 0; 667 668 RayInfoContainer::const_iterator it, it_end = rays.end(); 669 670 ViewCell *vc = leaf->GetViewCell(); 671 672 // add contributions from samples to the PVS 673 for (it = rays.begin(); it != it_end; ++ it) 674 { 675 int contribution = 0; 676 VssRay *ray = (*it).mRay; 677 678 if (ray->mTerminationObject) 679 contribution += vc->GetPvs().AddSample(ray->mTerminationObject); 680 681 if (ray->mOriginObject) 682 contribution += vc->GetPvs().AddSample(ray->mOriginObject); 683 684 if (contribution) 685 { 686 sampleContributions += contribution; 687 ++ contributingSamples; 688 } 689 //leaf->mVssRays.push_back(ray); 666 sampleContributions = 0; 667 contributingSamples = 0; 668 669 RayInfoContainer::const_iterator it, it_end = rays.end(); 670 671 ViewCell *vc = leaf->GetViewCell(); 672 673 // add contributions from samples to the PVS 674 for (it = rays.begin(); it != it_end; ++ it) 675 { 676 float sc = 0.0f; 677 VssRay *ray = (*it).mRay; 678 bool madeContrib = false; 679 float contribution; 680 if (ray->mTerminationObject) { 681 if (vc->GetPvs().AddSample(ray->mTerminationObject, ray->mPdf, contribution)) 682 madeContrib = true; 683 sc += contribution; 684 } 685 686 if (ray->mOriginObject) { 687 if (vc->GetPvs().AddSample(ray->mOriginObject, ray->mPdf, contribution)) 688 madeContrib = true; 689 sc += contribution; 690 } 691 692 sampleContributions += sc; 693 if (madeContrib) 694 ++ contributingSamples; 695 696 //leaf->mVssRays.push_back(ray); 690 697 } 691 698 } … … 1499 1506 << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 1500 1507 << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 1501 << "Area: " << data.mArea << " (min: " << mTermMinArea << "), "1508 // << "Area: " << data.mArea << " (min: " << mTermMinArea << "), " 1502 1509 << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 1503 1510 << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "=, " -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r551 r556 560 560 void AddToPvs(BspLeaf *leaf, 561 561 const RayInfoContainer &rays, 562 int &sampleContributions,562 float &sampleContributions, 563 563 int &contributingSamples); 564 564 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r542 r556 2180 2180 2181 2181 if (ray->mTerminationObject) 2182 vc->GetPvs().AddSample(ray->mTerminationObject );2182 vc->GetPvs().AddSample(ray->mTerminationObject, ray->mPdf); 2183 2183 2184 2184 if (ray->mOriginObject) 2185 vc->GetPvs().AddSample(ray->mOriginObject );2185 vc->GetPvs().AddSample(ray->mOriginObject, ray->mPdf); 2186 2186 } 2187 2187 } -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r554 r556 79 79 80 80 81 if (!mDetectEmptyViewSpace) 82 ray.mFlags &= ~Ray::CULL_BACKFACES; 83 81 if (!mDetectEmptyViewSpace) 82 ray.mFlags &= ~Ray::CULL_BACKFACES; 83 else 84 ray.mFlags |= Ray::CULL_BACKFACES; 85 84 86 if (mKdTree->CastRay(ray)) { 85 87 objectA = ray.intersections[0].mObject; … … 103 105 if (!mDetectEmptyViewSpace) 104 106 ray.mFlags &= ~Ray::CULL_BACKFACES; 107 else 108 ray.mFlags |= Ray::CULL_BACKFACES; 105 109 106 110 if (mKdTree->CastRay(ray)) { … … 120 124 // cast again to ensure that there is no objectA 121 125 SetupRay(ray, pointB, direction); 126 ray.mFlags |= Ray::CULL_BACKFACES; 122 127 if (mKdTree->CastRay(ray)) { 123 128 objectA = ray.intersections[0].mObject; -
trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h
r537 r556 65 65 66 66 // probability of this ray 67 float mP robability;67 float mPdf; 68 68 69 69 ////////////////////////////// … … 74 74 Intersectable *terminationObject, 75 75 const int pass = 0, 76 const float p robability= 1.0f76 const float pdf = 1.0f 77 77 ): 78 78 mMailbox(-1), … … 86 86 mViewCells(0), 87 87 mWeightedPvsContribution(0), 88 mP robability(probability)88 mPdf(pdf) 89 89 { 90 90 Precompute(); … … 98 98 mPass(0), 99 99 mViewCells(0), 100 mP robability(1.0f)100 mPdf(1.0f) 101 101 { 102 102 if (ray.sourceObject.mObject) -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r549 r556 13 13 #;../data/vienna/vienna-plane.x3d 14 14 # filename ../data/vienna/viewcells-25-sel.x3d 15 filename ../data/atlanta/atlanta2.x3d15 # filename ../data/atlanta/atlanta2.x3d 16 16 # filename ../data/soda/soda.dat 17 #filename ../data/soda/soda5.dat17 filename ../data/soda/soda5.dat 18 18 } 19 19 … … 25 25 # type vss 26 26 type rss 27 detectEmptyViewSpace false27 detectEmptyViewSpace true 28 28 } 29 29 … … 70 70 RssPreprocessor { 71 71 samplesPerPass 100000 72 initialSamples 100000 073 vssSamples 2000000074 vssSamplesPerPass 100000 072 initialSamples 100000 73 vssSamples 10000 74 vssSamplesPerPass 100000 75 75 useImportanceSampling true 76 76 … … 93 93 94 94 RssTree { 95 96 95 epsilon 1e-6 97 perObjectTree true96 perObjectTree false 98 97 99 98 maxDepth 40 100 minPvs 3101 minRays 3099 minPvs 1 100 minRays 100 102 101 minSize 0.001 103 102 maxCostRatio 1.0 … … 107 106 maxStaticMemory 100 108 107 109 #splitType regular108 splitType regular 110 109 # splitType heuristic 111 splitType hybrid112 splitUseOnlyDrivingAxis false110 # splitType hybrid 111 splitUseOnlyDrivingAxis true 113 112 importanceBasedCost false 114 113 … … 162 161 163 162 164 Sampling {163 SamplingPreprocessor { 165 164 totalSamples 10000000 166 165 samplesPerPass 3 … … 200 199 } 201 200 202 # filename ../data/soda/viewcells_soda5.xml203 filename ../data/atlanta/viewcells_atlanta2.xml201 filename ../data/soda/viewcells_soda5-2.xml 202 # filename ../data/atlanta/viewcells_atlanta2.xml 204 203 # filename ../data/atlanta/atlanta_viewcells_large.x3d 205 204 # filename ../data/vienna/viewcells-25-sel.x3d … … 284 283 } 285 284 286 Termination {287 # parameters used for autopartition288 minRays 100289 minPolygons -1290 maxDepth 30291 minPvs 2292 #minProbability 0.0001293 minProbabilty 0.000294 maxRayContribution 0.005295 maxCostRatio 0.9296 missTolerance 4297 #maxAccRayLength 100285 # Termination { 286 # # parameters used for autopartition 287 # minRays 100 288 # minPolygons -1 289 # maxDepth 30 290 # minPvs 2 291 # #minProbability 0.0001 292 # minProbabilty 0.000 293 # maxRayContribution 0.005 294 # maxCostRatio 0.9 295 # missTolerance 4 296 # #maxAccRayLength 100 298 297 299 maxViewCells 20000298 # maxViewCells 20000 300 299 301 # used for pvs criterium302 ct_div_ci 0.0303 }300 # # used for pvs criterium 301 # ct_div_ci 0.0 302 # } 304 303 305 304 splitUseOnlyDrivingAxis false -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r540 r556 84 84 85 85 // create a preprocessor thread 86 PreprocessorThread *pt = new PreprocessorThread(p );86 PreprocessorThread *pt = new PreprocessorThread(p, app); 87 87 88 88 // p->mSceneGraph->Export("soda.x3d"); … … 94 94 if (p->mUseGlRenderer) { 95 95 96 96 rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree); 97 97 // renderer->resize(640, 480); 98 98 rendererWidget->resize(640, 480); 99 99 rendererWidget->show(); 100 101 100 pt->start(QThread::LowPriority); 102 } else 103 { 101 } else{ 104 102 // just call the mail method -> will be executed in the main thread 105 103 pt->Main(); … … 111 109 if (app) 112 110 return app->exec(); 113 111 114 112 return 0; 115 113 } -
trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro
r549 r556 17 17 18 18 # debuc config 19 CONFIG += console warn_off thread releaseqt19 CONFIG += console warn_off thread debug qt 20 20 21 21 # RELEASE CONFIG
Note: See TracChangeset
for help on using the changeset viewer.