Changeset 556


Ignore:
Timestamp:
01/19/06 15:30:44 (18 years ago)
Author:
bittner
Message:

debug version looking for glrenderer bug...

Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp

    r544 r556  
    4949GlRenderer::~GlRenderer() 
    5050{ 
     51  cerr<<"gl renderer destructor..\n"; 
     52  if (sCgFragmentProgram) 
    5153        cgDestroyProgram(sCgFragmentProgram); 
     54  if (sCgContext) 
    5255        cgDestroyContext(sCgContext); 
     56  cerr<<"done."<<endl; 
    5357} 
    5458 
     
    283287                                                         &pixelCount); 
    284288         
    285         pErrorPixels = (100.f*pixelCount)/(GetWidth()*GetHeight()); 
     289        pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight()); 
    286290  } 
    287291   
     
    343347                  errorPixels++; 
    344348                } 
    345         pErrorPixels = (100.f*errorPixels)/(im1.height()*im1.width()); 
     349        pErrorPixels = ((float)errorPixels)/(im1.height()*im1.width()); 
    346350  } 
    347351 
     
    466470        } 
    467471  } 
    468    
     472 
     473  glFinish(); 
    469474  doneCurrent(); 
    470475 
    471476  cout<<endl<<flush; 
    472   mRenderingFinished.wakeAll(); 
     477  //  mRenderingFinished.wakeAll(); 
    473478} 
    474479 
     
    940945void GlRendererBuffer::InitGL() 
    941946{ 
    942         GlRenderer::InitGL(); 
     947 makeCurrent();  
     948 GlRenderer::InitGL(); 
     949#if 0 
    943950        // initialise dual depth buffer textures 
    944951        glGenTextures(1, &frontDepthMap); 
     
    980987  } 
    981988 
    982   sCgFragmentProgram = cgCreateProgramFromFile(sCgContext,               
     989 
     990 sCgFragmentProgram = cgCreateProgramFromFile(sCgContext, 
    983991                                                                                           CG_SOURCE, "../src/dual_depth.cg", 
    984992                                                                                           sCgFragmentProfile, 
     
    991999  cgGLLoadProgram(sCgFragmentProgram); 
    9921000  cgGLBindProgram(sCgFragmentProgram); 
    993   
    994   Debug << "---- PROGRAM BEGIN ----\n" <<  
     1001 
     1002  Debug << "---- PROGRAM BEGIN ----\n" << 
    9951003          cgGetProgramString(sCgFragmentProgram, CG_COMPILED_PROGRAM) << "---- PROGRAM END ----\n"; 
     1004 
     1005#endif 
     1006  doneCurrent(); 
    9961007} 
    9971008 
     
    10711082GlDebuggerWidget::~GlDebuggerWidget() 
    10721083{ 
    1073         mRenderBuffer->releaseFromDynamicTexture(); 
    1074         glDeleteTextures(1, &dynamicTexture); 
    1075          
    1076         DEL_PTR(mRenderBuffer); 
     1084 mRenderBuffer->releaseFromDynamicTexture(); 
     1085   glDeleteTextures(1, &dynamicTexture); 
     1086          
     1087         DEL_PTR(mRenderBuffer); 
    10771088} 
    10781089 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h

    r540 r556  
    122122        QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells, tree) { 
    123123 
    124         mPvsStatFrames = 10000; 
     124        mPvsStatFrames = 5000; 
    125125        mPvsErrorBuffer.resize(mPvsStatFrames); 
    126126        ClearErrorBuffer(); 
    127127 
    128         makeCurrent(); 
    129         InitGL(); 
    130         doneCurrent(); 
     128//      makeCurrent(); 
     129//      InitGL(); 
     130//      doneCurrent(); 
    131131 
    132132        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Intersectable.h

    r497 r556  
    7575                                                                         VssRayContainer &rays 
    7676                                                                         ) {return 0;} 
    77    
     77 
     78  static bool GreaterCounter(const Intersectable *a, 
     79                                                         const Intersectable *b) { 
     80        return a->mCounter > b->mCounter; 
     81  } 
    7882}; 
    7983 
  • trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp

    r535 r556  
    922922            // kd tree PVS 
    923923                float contribution; 
    924                 if (leaf->mKdPvs.AddSample(node, contribution)) 
     924                if (leaf->mKdPvs.AddSample(node, 1.0f, contribution)) 
    925925              totalPvsSize++; 
    926926          } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Makefile

    r549 r556  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.0) on: po 16. I 20:32:45 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.0) on: ?t 19. I 11:57:31 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
     
    77############################################################################# 
    88 
    9 first: release 
    10 install: release-install 
    11 uninstall: release-uninstall 
     9first: debug 
     10install: debug-install 
     11uninstall: debug-uninstall 
    1212MAKEFILE      = Makefile 
    1313QMAKE         = qmake 
     
    2727MKDIR         = mkdir 
    2828SUBTARGETS    =  \ 
    29                 release \ 
    30                 debug 
     29                debug \ 
     30                release 
    3131 
     32debug: $(MAKEFILE).Debug FORCE 
     33        $(MAKE) -f $(MAKEFILE).Debug 
     34debug-make_default: $(MAKEFILE).Debug FORCE 
     35        $(MAKE) -f $(MAKEFILE).Debug  
     36debug-make_first: $(MAKEFILE).Debug FORCE 
     37        $(MAKE) -f $(MAKEFILE).Debug first 
     38debug-all: $(MAKEFILE).Debug FORCE 
     39        $(MAKE) -f $(MAKEFILE).Debug all 
     40debug-clean: $(MAKEFILE).Debug FORCE 
     41        $(MAKE) -f $(MAKEFILE).Debug clean 
     42debug-distclean: $(MAKEFILE).Debug FORCE 
     43        $(MAKE) -f $(MAKEFILE).Debug distclean 
     44debug-install: $(MAKEFILE).Debug FORCE 
     45        $(MAKE) -f $(MAKEFILE).Debug install 
     46debug-uninstall: $(MAKEFILE).Debug FORCE 
     47        $(MAKE) -f $(MAKEFILE).Debug uninstall 
    3248release: $(MAKEFILE).Release FORCE 
    3349        $(MAKE) -f $(MAKEFILE).Release 
     
    4662release-uninstall: $(MAKEFILE).Release FORCE 
    4763        $(MAKE) -f $(MAKEFILE).Release uninstall 
    48 debug: $(MAKEFILE).Debug FORCE 
    49         $(MAKE) -f $(MAKEFILE).Debug 
    50 debug-make_default: $(MAKEFILE).Debug FORCE 
    51         $(MAKE) -f $(MAKEFILE).Debug  
    52 debug-make_first: $(MAKEFILE).Debug FORCE 
    53         $(MAKE) -f $(MAKEFILE).Debug first 
    54 debug-all: $(MAKEFILE).Debug FORCE 
    55         $(MAKE) -f $(MAKEFILE).Debug all 
    56 debug-clean: $(MAKEFILE).Debug FORCE 
    57         $(MAKE) -f $(MAKEFILE).Debug clean 
    58 debug-distclean: $(MAKEFILE).Debug FORCE 
    59         $(MAKE) -f $(MAKEFILE).Debug distclean 
    60 debug-install: $(MAKEFILE).Debug FORCE 
    61         $(MAKE) -f $(MAKEFILE).Debug install 
    62 debug-uninstall: $(MAKEFILE).Debug FORCE 
    63         $(MAKE) -f $(MAKEFILE).Debug uninstall 
    6464 
    6565Makefile: preprocessor.pro  D:/Qt/4.1.0/mkspecs/win32-msvc.net\qmake.conf D:/Qt/4.1.0/mkspecs/qconfig.pri \ 
     
    6868                D:\Qt\4.1.0\mkspecs\features\default_pre.prf \ 
    6969                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 \ 
    7171                D:\Qt\4.1.0\mkspecs\features\debug_and_release.prf \ 
    7272                D:\Qt\4.1.0\mkspecs\features\default_post.prf \ 
     
    8989D:\Qt\4.1.0\mkspecs\features\default_pre.prf: 
    9090D:\Qt\4.1.0\mkspecs\features\win32\default_pre.prf: 
    91 D:\Qt\4.1.0\mkspecs\features\release.prf: 
     91D:\Qt\4.1.0\mkspecs\features\debug.prf: 
    9292D:\Qt\4.1.0\mkspecs\features\debug_and_release.prf: 
    9393D:\Qt\4.1.0\mkspecs\features\default_post.prf: 
     
    109109qmake_all: FORCE 
    110110 
    111 make_default: release-make_default debug-make_default FORCE 
    112 make_first: release-make_first debug-make_first FORCE 
    113 all: release-all debug-all FORCE 
    114 clean: release-clean debug-clean FORCE 
     111make_default: debug-make_default release-make_default FORCE 
     112make_first: debug-make_first release-make_first FORCE 
     113all: debug-all release-all FORCE 
     114clean: debug-clean release-clean FORCE 
    115115        -$(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 
     120distclean: debug-distclean release-distclean FORCE 
    117121        -$(DEL_FILE) Makefile 
    118122 
     123debug-mocclean: $(MAKEFILE).Debug 
     124        $(MAKE) -f $(MAKEFILE).Debug mocclean 
    119125release-mocclean: $(MAKEFILE).Release 
    120126        $(MAKE) -f $(MAKEFILE).Release mocclean 
    121 debug-mocclean: $(MAKEFILE).Debug 
    122         $(MAKE) -f $(MAKEFILE).Debug mocclean 
    123 mocclean: release-mocclean debug-mocclean 
     127mocclean: debug-mocclean release-mocclean 
    124128 
     129debug-mocables: $(MAKEFILE).Debug 
     130        $(MAKE) -f $(MAKEFILE).Debug mocables 
    125131release-mocables: $(MAKEFILE).Release 
    126132        $(MAKE) -f $(MAKEFILE).Release mocables 
    127 debug-mocables: $(MAKEFILE).Debug 
    128         $(MAKE) -f $(MAKEFILE).Debug mocables 
    129 mocables: release-mocables debug-mocables 
     133mocables: debug-mocables release-mocables 
    130134FORCE: 
    131135 
     136$(MAKEFILE).Debug: Makefile 
    132137$(MAKEFILE).Release: Makefile 
    133 $(MAKEFILE).Debug: Makefile 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r540 r556  
    3333Preprocessor::~Preprocessor() 
    3434{ 
     35  cerr<<"Deleting view cells manager...\n"; 
    3536  DEL_PTR(mViewCellsManager); 
     37  cerr<<"done.\n"; 
     38  cerr<<"Deleting bsp tree...\n"; 
    3639  DEL_PTR(mBspTree); 
     40  cerr<<"done.\n"; 
     41  cerr<<"Deleting kd tree...\n"; 
    3742  DEL_PTR(mKdTree); 
     43  cerr<<"done.\n"; 
     44  cerr<<"Deleting vspkd tree...\n"; 
    3845  DEL_PTR(mVspKdTree); 
     46  cerr<<"done.\n"; 
     47  cerr<<"Deleting vspbsp tree...\n"; 
    3948  DEL_PTR(mVspBspTree); 
     49  cerr<<"done.\n"; 
    4050} 
    4151 
     
    258268                mViewCellsFilename = buf; 
    259269        } 
     270 
    260271        if (mUseGlRenderer || mUseGlDebugger) 
    261272        { 
     
    263274                // renderer must be initialised 
    264275                renderer = new GlRendererBuffer(1024, 768, mSceneGraph, mViewCellsManager, mKdTree); 
    265                 renderer->makeCurrent(); 
     276                //              renderer->makeCurrent(); 
    266277        } 
    267278 
  • trunk/VUT/GtpVisibilityPreprocessor/src/PreprocessorThread.cpp

    r492 r556  
    1313{ 
    1414  mPreprocessor = p; 
     15  connect(this, SIGNAL(finished()), qApp, SLOT(closeAllWindows(void))); 
    1516} 
    1617 
     
    2122  if (1) { 
    2223    mPreprocessor->ComputeVisibility(); 
    23     mPreprocessor->ExportPreprocessedData("scene.vis"); 
     24        //      mPreprocessor->ExportPreprocessedData("scene.vis"); 
    2425  } 
    2526   
    2627  Camera camera; 
     28 
    2729  if (0) { 
    2830    camera.LookAtBox(mPreprocessor->mKdTree->GetBox()); 
     
    4345  } 
    4446 
    45   QApplication::quit(); 
     47 
     48  cerr<<"Preprocessor main finished...\n"; 
    4649   
    4750} 
     51 
     52PreprocessorThread::~PreprocessorThread() 
     53{ 
     54  cerr<<"Preprocessor thread destructor...\n"; 
     55} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/PreprocessorThread.h

    r492 r556  
    1313public: 
    1414  PreprocessorThread(Preprocessor *p, QObject *parent = 0); 
    15   ~PreprocessorThread() {} 
     15  ~PreprocessorThread(); 
    1616 
    1717  void Main(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h

    r492 r556  
    2525template<typename T>  
    2626struct PvsData { 
    27   int mVisibleSamples; 
     27  //  int mVisibleSamples; 
     28  // sum of probability density of visible sample rays 
     29  float mSumPdf; 
    2830  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; } 
    3037}; 
    3138 
     
    4653  int GetSize() const {return (int)mEntries.size();} 
    4754  bool Empty() const {return mEntries.empty();} 
     55 
     56  /** Normalize the visibility of entries in order to get comparable 
     57          results */ 
     58   
     59  void NormalizeMaximum(); 
    4860   
    4961  /** Merges pvs of a and pvs of b into this pvs. 
     
    6173  PvsData<T> *Find(T sample); 
    6274 
    63   bool GetSampleContribution(T sample, float &contribution); 
     75  bool GetSampleContribution(T sample, const float pdf, float &contribution); 
    6476   
    6577  /** Adds sample to PVS.  
     
    6779          @returns true if sample was not already in PVS. 
    6880  */ 
    69   bool AddSample(T sample, float &contribution); 
     81  bool AddSample(T sample, const float pdf, float &contribution); 
    7082 
    7183  /** Adds sample to PVS. 
    7284          @returns contribution of sample (0 or 1) 
    7385  */ 
    74   int AddSample(T sample); 
     86  float AddSample(T sample, const float pdf); 
    7587   
    7688  /** Adds one pvs to another one. 
     
    94106          @param visibleSampels number of references to be removed 
    95107  */ 
    96   bool RemoveSample(T sample, const int visibleSamples); 
     108  bool RemoveSample(T sample, const float pdf); 
    97109 
    98110  /// Map of PVS entries 
     
    130142                 
    131143                if (data) 
    132                         data->mVisibleSamples += (*it).second.mVisibleSamples; 
     144                        data->mSumPdf += (*it).second.mSumPdf; 
    133145                else 
    134146                        mEntries.insert(*it); 
     
    159171 
    160172template <typename T> 
    161 int 
    162 Pvs<T>::AddSample(T sample) 
     173float 
     174Pvs<T>::AddSample(T sample, const float pdf) 
    163175{ 
    164176  PvsData<T> *data = Find(sample); 
    165177   
    166178  if (data)  { 
    167         return ++data->mVisibleSamples; 
     179        data->mSumPdf+=pdf; 
     180        return data->mSumPdf; 
    168181  } 
    169182  else { 
    170         mEntries[sample] = PvsData<T>(1); 
    171         return 1; 
     183        mEntries[sample] = PvsData<T>(pdf); 
     184        return pdf; 
    172185  } 
    173186} 
     
    175188template <typename T> 
    176189bool 
    177 Pvs<T>::AddSample(T sample, float &contribution) 
     190Pvs<T>::AddSample(T sample, 
     191                                  const float pdf, 
     192                                  float &contribution) 
    178193{ 
    179194  PvsData<T> *data = Find(sample); 
    180195   
    181196  if (data)  { 
    182         data->mVisibleSamples++; 
    183         contribution = 1.0f/data->mVisibleSamples; 
     197        data->mSumPdf+=pdf; 
     198        contribution = pdf/data->mSumPdf; 
    184199        return false; 
    185200  } 
    186201  else { 
    187         mEntries[sample] = PvsData<T>(1); 
     202        mEntries[sample] = PvsData<T>(pdf); 
    188203        contribution = 1.0f; 
    189204        return true; 
     
    193208template <typename T> 
    194209bool 
    195 Pvs<T>::GetSampleContribution(T sample, float &contribution)  
     210Pvs<T>::GetSampleContribution(T sample, 
     211                                                          const float pdf, 
     212                                                          float &contribution)  
    196213{ 
    197214  PvsData<T> *data = Find(sample); 
    198215   
    199216  if (data)  { 
    200         contribution = 1.0f/(data->mVisibleSamples + 1); 
     217        contribution = pdf/(data->mSumPdf + pdf); 
    201218        return false; 
    202219  } 
     
    208225 
    209226template <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; 
     227bool 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; 
    225243} 
    226244 
     
    228246int Pvs<T>::AddPvs(const Pvs<T> &pvs) 
    229247{ 
    230         std::map<T, PvsData<T>, LtSample<T> >:: 
    231                 const_iterator it, it_end = pvs.mEntries.end(); 
    232  
    233         float contri; 
    234         // output PVS of view cell 
    235         for (it = pvs.mEntries.begin(); it != it_end; ++ it)  
    236                 AddSample((*it).first, contri); 
    237  
    238         return GetSize(); 
     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(); 
    239257} 
    240258  
     
    242260int Pvs<T>::SubtractPvs(const Pvs<T> &pvs) 
    243261{ 
    244         std::map<T, PvsData<T>, LtSample<T> >:: 
    245                 const_iterator it, it_end = pvs.mEntries.end(); 
    246  
    247         // output PVS of view cell 
    248         for (it = pvs.mEntries.begin(); it != it_end; ++ it)  
    249                 RemoveSample((*it).first, (*it).second.mVisibleSamples); 
    250  
    251         return GetSize(); 
     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(); 
    252270} 
    253271 
     
    262280                entries.push_back((*it)->first); 
    263281} 
     282 
     283template <typename T> 
     284void 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 
    264306 
    265307/** Class instantiating the Pvs template for kd tree nodes. 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h

    r537 r556  
    304304  Vector3 mOrigin; 
    305305  Vector3 mDirection; 
    306   float mProbability; 
     306  float mPdf; 
    307307 
    308308  SimpleRay() {} 
    309309  SimpleRay(const Vector3 &o, const Vector3 &d, const float p=1.0f): 
    310         mOrigin(o), mDirection(d), mProbability(p) {} 
     310        mOrigin(o), mDirection(d), mPdf(p) {} 
    311311}; 
    312312 
     
    315315public: 
    316316   
    317   float mSumProbabilities; 
    318    
    319   SimpleRayContainer():vector<SimpleRay>(), mSumProbabilities(0.0f) {} 
    320    
    321   void NormalizeProbabilities() { 
     317  float mSumPdf; 
     318   
     319  SimpleRayContainer():vector<SimpleRay>(), mSumPdf(0.0f) {} 
     320   
     321  void NormalizePdf() { 
    322322        iterator it = begin(); 
    323         float c = 1.0f/mSumProbabilities; 
     323        float c = 1.0f/mSumPdf; 
    324324        for (; it != end(); it++) 
    325           (*it).mProbability*=c; 
     325          (*it).mPdf*=c; 
    326326  } 
    327327   
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r549 r556  
    8585  if (!mDetectEmptyViewSpace) 
    8686        ray.mFlags &= ~Ray::CULL_BACKFACES; 
     87  else 
     88        ray.mFlags |= Ray::CULL_BACKFACES; 
     89 
    8790 
    8891  // cast ray to KD tree to find intersection with other objects 
     
    113116  if (!mDetectEmptyViewSpace) 
    114117        ray.mFlags &= ~Ray::CULL_BACKFACES; 
     118  else 
     119        ray.mFlags |= Ray::CULL_BACKFACES; 
    115120 
    116121  if (mKdTree->CastRay(ray)) { 
     
    130135        // cast again to ensure that there is no objectA 
    131136        SetupRay(ray, pointB, direction); 
     137        ray.mFlags |= Ray::CULL_BACKFACES; 
    132138        if (mKdTree->CastRay(ray)) { 
    133139          objectA = ray.intersections[0].mObject; 
     
    315321  //    exporter->ExportKdTree(*mKdTree); 
    316322  exporter->SetFilled(); 
    317   // temporarily do not export the scene 
    318   if (0) 
     323  // $$JB temporarily do not export the scene 
     324  if (1) 
    319325        exporter->ExportScene(mSceneGraph->mRoot); 
    320326  exporter->SetWireframe(); 
     
    459465        //      renderer->mRenderingFinished.wait(&mutex); 
    460466        //      mutex.unlock(); 
     467 
    461468        renderer->EvalPvsStat(); 
    462469        mStats << 
     
    470477RssPreprocessor::ComputeVisibility() 
    471478{ 
     479 
     480  if (renderer) 
     481        renderer->InitGL(); 
    472482   
    473483  //  connect(this, SIGNAL(EvalPvsStat()), renderer, SLOT(EvalPvsStat()) ); 
     
    698708                Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 
    699709                rays.push_back(SimpleRay(viewpoint, direction, 1.0f)); 
    700                 rays.mSumProbabilities+=1.0f; 
     710                rays.mSumPdf += 1.0f; 
    701711          } 
    702712        } else { 
     
    704714        } 
    705715 
    706         rays.NormalizeProbabilities(); 
     716        rays.NormalizePdf(); 
    707717         
    708718        for (int i=0; i < rays.size(); i++) 
    709           CastRay(rays[i].mOrigin, rays[i].mDirection, rays[i].mProbability, vssRays); 
     719          CastRay(rays[i].mOrigin, rays[i].mDirection, rays[i].mPdf, vssRays); 
    710720 
    711721         
     
    802812  if (mUseViewcells) { 
    803813 
    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"; 
    818829  delete rssTree; 
     830  cerr<<"Done.\n"; 
     831 
    819832   
    820833  return true; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp

    r551 r556  
    10301030  //  if ( (int)(leaf->rays.size()) < termMinCost) 
    10311031  //    stat.minCostNodes++; 
    1032   if ( leaf->GetPvsSize() < termMinPvs) 
     1032  if ( leaf->GetPvsSize() <= termMinPvs) 
    10331033        stat.minPvsNodes++; 
    10341034 
    1035   if ( leaf->GetPvsSize() < termMinRays) 
     1035  if ( leaf->GetPvsSize() <= termMinRays) 
    10361036        stat.minRaysNodes++; 
    10371037 
     
    10511051RssTree::TerminationCriteriaSatisfied(RssTreeLeaf *leaf) 
    10521052{ 
    1053   return ( (leaf->GetPvsSize() < termMinPvs) || 
    1054                    (leaf->rays.size() < termMinRays) || 
     1053  return ( (leaf->GetPvsSize() <= termMinPvs) || 
     1054                   (leaf->rays.size() <= termMinRays) || 
    10551055                   //                    (leaf->GetAvgRayContribution() > termMaxRayContribution ) || 
    10561056                   (leaf->depth >= termMaxDepth) || 
     
    20812081          ri++) { 
    20822082        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   
    20912098  float extendedConvexCombinationProb = 0.0f; //0.7f 
    2092   float silhouetteCheckPercentage = 0.0f; //0.5f 
     2099  float silhouetteCheckPercentage = 0.5f; //0.5f 
    20932100  for (int i=0; generated < numberOfRays && i < numberOfTries; i++) { 
    20942101        bool useExtendedConvexCombination = ((nrays >= 2) && (Random(1.0f) < 
     
    21792186                  oi++) { 
    21802187                Intersectable *object = *oi; 
    2181                  
    21822188                if ( object->CastRay(traversalRay) ) { 
    21832189                  intersects = true; 
     
    21972203   
    21982204  //  cout<<"desired="<<numberOfRays<<" tries="<<i<<endl; 
    2199   // assign probabilitites to the generated rays 
    2200   float p = (box.GetVolume()*dirBox.GetVolume())/generated; 
     2205  // assign pdfs to the generated rays 
     2206  float p = (box.GetVolume()*dirBox.GetVolume())/i; 
    22012207  for (i=startIndex; i < rays.size(); i++) { 
    2202         rays[i].mProbability = p; 
    2203         rays.mSumProbabilities += p; 
     2208        rays[i].mPdf = p; 
     2209        rays.mSumPdf += p; 
    22042210  } 
    22052211   
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r551 r556  
    24702470                float relContribution; 
    24712471                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); 
    24732475                 
    24742476                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                 
    24772481                if (contribution) 
    24782482                { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r555 r556  
    458458                        bool added = 
    459459                        viewcell->GetPvs().AddSample(ray.mTerminationObject, 
    460                                                                                         contribution 
    461                                                                                         ); 
     460                                                                                 ray.mPdf, 
     461                                                                                 contribution 
     462                                                                                 ); 
    462463                        if (added) 
    463464                        ray.mPvsContribution++; 
     
    473474                        float contribution; 
    474475                        if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 
    475                                                                                                                 contribution 
    476                                                                                                                 )) 
    477                         ray.mPvsContribution++; 
     476                                                                                                                 ray.mPdf, 
     477                                                                                                                 contribution 
     478                                                                                                                 )) 
     479                          ray.mPvsContribution++; 
    478480                        ray.mRelativePvsContribution += contribution; 
    479481                } 
    480  
     482                 
    481483                for (it = viewcells.begin(); it != viewcells.end(); ++it) { 
    482                         ViewCell *viewcell = *it; 
    483                         // if ray not outside of view space 
    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); 
    485487                } 
    486488        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r555 r556  
    300300        virtual void ExportColor(Exporter *exporter, ViewCell *vc) const = 0; 
    301301 
    302          
     302 
     303  virtual float GetViewSpaceVolume() { 
     304        return mViewSpaceBox.GetVolume()*(2.0f*sqr(M_PI)); 
     305  } 
    303306        /** Creates meshes from the view cells. 
    304307        */ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParser.cpp

    r508 r556  
    197197 
    198198                                ObjectContainer::iterator oit = 
    199                                         lower_bound(mObjects->begin(), mObjects->end(), &dummyInst, ilt); 
    200                          
     199                                  lower_bound(mObjects->begin(), mObjects->end(), &dummyInst, ilt); 
     200                                 
    201201                                Intersectable *obj = *oit; 
    202202                                 
    203203                                if (obj->GetId() == objId) 
    204204                                { 
    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); 
    206209                                } 
    207210                                else 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r555 r556  
    493493         
    494494                //-- 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); 
    497498 
    498499                mStat.contributingSamples += conSamp; 
     
    660661void VspBspTree::AddToPvs(BspLeaf *leaf, 
    661662                                                  const RayInfoContainer &rays, 
    662                                                   int &sampleContributions, 
     663                                                  float &sampleContributions, 
    663664                                                  int &contributingSamples) 
    664665{ 
    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); 
    690697        } 
    691698} 
     
    14991506                  << "Depth: " << data.mDepth << " (max: " << mTermMaxDepth << "), " 
    15001507                  << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 
    1501                   << "Area: " << data.mArea << " (min: " << mTermMinArea << "), " 
     1508          //              << "Area: " << data.mArea << " (min: " << mTermMinArea << "), " 
    15021509                  << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 
    15031510                  << "#pvs: " << leaf->GetViewCell()->GetPvs().GetSize() << "=, " 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r551 r556  
    560560        void AddToPvs(BspLeaf *leaf, 
    561561                                  const RayInfoContainer &rays,  
    562                                   int &sampleContributions, 
     562                                  float &sampleContributions, 
    563563                                  int &contributingSamples); 
    564564 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp

    r542 r556  
    21802180 
    21812181                if (ray->mTerminationObject) 
    2182                   vc->GetPvs().AddSample(ray->mTerminationObject); 
     2182                  vc->GetPvs().AddSample(ray->mTerminationObject, ray->mPdf); 
    21832183 
    21842184                if (ray->mOriginObject) 
    2185                   vc->GetPvs().AddSample(ray->mOriginObject); 
     2185                  vc->GetPvs().AddSample(ray->mOriginObject, ray->mPdf); 
    21862186        } 
    21872187} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r554 r556  
    7979 
    8080 
    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 
    8486  if (mKdTree->CastRay(ray)) { 
    8587        objectA = ray.intersections[0].mObject; 
     
    103105  if (!mDetectEmptyViewSpace) 
    104106        ray.mFlags &= ~Ray::CULL_BACKFACES; 
     107                                                           else 
     108                                                                 ray.mFlags |= Ray::CULL_BACKFACES; 
    105109 
    106110  if (mKdTree->CastRay(ray)) { 
     
    120124        // cast again to ensure that there is no objectA 
    121125        SetupRay(ray, pointB, direction); 
     126          ray.mFlags |= Ray::CULL_BACKFACES; 
    122127        if (mKdTree->CastRay(ray)) { 
    123128          objectA = ray.intersections[0].mObject; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h

    r537 r556  
    6565 
    6666  // probability of this ray 
    67   float mProbability; 
     67  float mPdf; 
    6868   
    6969  ////////////////////////////// 
     
    7474                 Intersectable *terminationObject, 
    7575                 const int pass = 0, 
    76                  const float probability = 1.0f 
     76                 const float pdf = 1.0f 
    7777                 ): 
    7878        mMailbox(-1), 
     
    8686        mViewCells(0), 
    8787        mWeightedPvsContribution(0), 
    88         mProbability(probability) 
     88        mPdf(pdf) 
    8989  { 
    9090    Precompute(); 
     
    9898        mPass(0), 
    9999        mViewCells(0), 
    100         mProbability(1.0f) 
     100        mPdf(1.0f) 
    101101  { 
    102102        if (ray.sourceObject.mObject) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r549 r556  
    1313#;../data/vienna/vienna-plane.x3d 
    1414# filename ../data/vienna/viewcells-25-sel.x3d 
    15 filename ../data/atlanta/atlanta2.x3d 
     15# filename ../data/atlanta/atlanta2.x3d 
    1616# filename ../data/soda/soda.dat 
    17 # filename ../data/soda/soda5.dat 
     17filename ../data/soda/soda5.dat 
    1818} 
    1919 
     
    2525#       type vss 
    2626        type rss 
    27         detectEmptyViewSpace false 
     27        detectEmptyViewSpace true 
    2828} 
    2929 
     
    7070RssPreprocessor { 
    7171        samplesPerPass  100000 
    72         initialSamples 1000000 
    73         vssSamples 20000000 
    74         vssSamplesPerPass 1000000 
     72        initialSamples 100000 
     73        vssSamples 10000 
     74        vssSamplesPerPass 100000 
    7575        useImportanceSampling true 
    7676 
     
    9393 
    9494RssTree { 
    95  
    9695        epsilon         1e-6 
    97         perObjectTree true 
     96        perObjectTree false 
    9897 
    9998        maxDepth        40 
    100         minPvs          3 
    101         minRays         30 
     99        minPvs          1 
     100        minRays         100 
    102101        minSize         0.001 
    103102        maxCostRatio 1.0 
     
    107106        maxStaticMemory 100 
    108107 
    109 #       splitType regular 
     108        splitType regular 
    110109#       splitType heuristic 
    111         splitType hybrid 
    112         splitUseOnlyDrivingAxis false 
     110#       splitType hybrid 
     111        splitUseOnlyDrivingAxis true 
    113112        importanceBasedCost false 
    114113 
     
    162161 
    163162 
    164 Sampling { 
     163SamplingPreprocessor { 
    165164        totalSamples 10000000 
    166165        samplesPerPass  3 
     
    200199        } 
    201200         
    202 #       filename ../data/soda/viewcells_soda5.xml 
    203         filename ../data/atlanta/viewcells_atlanta2.xml 
     201        filename ../data/soda/viewcells_soda5-2.xml 
     202#       filename ../data/atlanta/viewcells_atlanta2.xml 
    204203#       filename ../data/atlanta/atlanta_viewcells_large.x3d 
    205204#       filename ../data/vienna/viewcells-25-sel.x3d 
     
    284283        } 
    285284         
    286         Termination { 
    287                 # parameters used for autopartition 
    288                 minRays                 100 
    289                 minPolygons             -1 
    290                 maxDepth                30 
    291                 minPvs                  2 
    292                 #minProbability         0.0001 
    293                 minProbabilty           0.000 
    294                 maxRayContribution      0.005 
    295                 maxCostRatio            0.9 
    296                 missTolerance           4 
    297                 #maxAccRayLength        100 
     285#       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 
    298297                 
    299                 maxViewCells            20000 
     298#               maxViewCells            20000 
    300299                 
    301                 # used for pvs criterium 
    302                 ct_div_ci 0.0 
    303         } 
     300#               # used for pvs criterium 
     301#               ct_div_ci 0.0 
     302#       } 
    304303         
    305304        splitUseOnlyDrivingAxis false 
  • trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp

    r540 r556  
    8484 
    8585  // create a preprocessor thread 
    86   PreprocessorThread *pt = new PreprocessorThread(p); 
     86  PreprocessorThread *pt = new PreprocessorThread(p, app); 
    8787 
    8888  //  p->mSceneGraph->Export("soda.x3d"); 
     
    9494  if (p->mUseGlRenderer) { 
    9595         
    96           rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree); 
     96        rendererWidget = new GlRendererWidget(p->mSceneGraph, p->mViewCellsManager, p->mKdTree); 
    9797        //  renderer->resize(640, 480); 
    9898        rendererWidget->resize(640, 480); 
    9999        rendererWidget->show(); 
    100  
    101100        pt->start(QThread::LowPriority); 
    102   } else 
    103   { 
     101  } else{ 
    104102        // just call the mail method -> will be executed in the main thread 
    105103        pt->Main(); 
     
    111109  if (app) 
    112110        return app->exec(); 
    113  
     111   
    114112  return 0; 
    115113} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro

    r549 r556  
    1717 
    1818# debuc config 
    19 CONFIG          += console warn_off thread release qt 
     19CONFIG          += console warn_off thread debug qt 
    2020 
    2121# RELEASE CONFIG 
Note: See TracChangeset for help on using the changeset viewer.