Changeset 576


Ignore:
Timestamp:
01/25/06 14:35:01 (18 years ago)
Author:
bittner
Message:

rss preprocessor debugging + merge

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

Legend:

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

    r572 r576  
    4444  mViewDirection = Vector3(0,0,1); 
    4545  //  timerId = startTimer(10); 
     46  // debug coords for atlanta 
     47  mViewPoint = Vector3(3473, 6.778, -1699); 
     48  mViewDirection = Vector3(-0.2432, 0, 0.97); 
     49   
    4650  mFrame = 0; 
    4751  mWireFrame = false; 
    4852  environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 
     53  mSnapErrorFrames = false; 
     54  mSnapPrefix = ""; 
    4955 
    5056} 
     
    177183  glGetOcclusionQueryuivNV = (PFNGLGETOCCLUSIONQUERYUIVNVPROC) 
    178184        wglGetProcAddress("glGetOcclusionQueryuivNV"); 
    179 } 
    180  
     185 
     186        glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 
     187 
     188} 
     189 
     190void 
     191GlRendererWidget::RenderInfo() 
     192{ 
     193  QString s; 
     194  s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f)", 
     195                        mFrame, 
     196                        mViewPoint.x, 
     197                        mViewPoint.y, 
     198                        mViewPoint.z, 
     199                        mViewDirection.x, 
     200                        mViewDirection.y, 
     201                        mViewDirection.z 
     202 
     203                        ); 
     204  renderText(0,20,s); 
     205} 
    181206 
    182207 
     
    245270                                                                   KdTree *tree): 
    246271QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells, tree) { 
    247   
    248272  
    249273 environment->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames); 
     
    256280 
    257281float 
    258 GlRenderer::GetPixelError() 
     282GlRendererBuffer::GetPixelError() 
    259283{ 
    260284  float pErrorPixels = -1.0f; 
     
    262286  glReadBuffer(GL_BACK); 
    263287   
    264   mUseFalseColors = true; 
    265    
     288  //  mUseFalseColors = true; 
     289   
     290  mUseFalseColors = false; 
    266291 
    267292  static int query = -1; 
     
    311336        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    312337 
     338        glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); 
     339 
    313340        // Render PVS 
    314341        std::map<Intersectable *, 
     
    320347          RenderIntersectable(object); 
    321348        } 
     349 
     350        //      glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 
     351        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     352        mUseFalseColors = true; 
    322353 
    323354        glBeginOcclusionQueryNV(query); 
     
    337368         
    338369        pErrorPixels = ((float)pixelCount)/(GetWidth()*GetHeight()); 
     370        if (mSnapErrorFrames && pErrorPixels > 0.01) { 
     371           
     372          char filename[256]; 
     373          sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
     374          QImage im = toImage(); 
     375          im.save(mSnapPrefix + filename, "PNG"); 
     376          if (1) { //0 && mFrame == 1543) { 
     377                int x,y; 
     378                int lastIndex = -1; 
     379                for (y=0; y < im.height(); y++) 
     380                  for (x=0; x < im.width(); x++) { 
     381                        QRgb p = im.pixel(x,y); 
     382                        int index = qRed(p) + (qGreen(p)<<8) + (qBlue(p)<<16); 
     383                        if (qGreen(p) != 255 && index!=0) { 
     384                          if (index != lastIndex) { 
     385                                Debug<<"ei="<<index<<" "; 
     386                                lastIndex = index; 
     387                          } 
     388                        } 
     389                  } 
     390          } 
     391 
     392 
     393          mUseFalseColors = false; 
     394          glPushAttrib(GL_CURRENT_BIT); 
     395          glColor3f(0,1,0); 
     396          glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     397          SetupCamera(); 
     398          glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     399           
     400          // Render PVS 
     401          std::map<Intersectable *, 
     402                PvsData<Intersectable *>, 
     403                LtSample<Intersectable *> >::const_iterator it = viewcell->GetPvs().mEntries.begin(); 
     404           
     405          for (; it != viewcell->GetPvs().mEntries.end(); ++ it) { 
     406                Intersectable *object = (*it).first; 
     407                RenderIntersectable(object); 
     408          } 
     409 
     410          im = toImage(); 
     411          sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); 
     412          im.save(mSnapPrefix + filename, "PNG"); 
     413          glPopAttrib(); 
     414        } 
     415        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    339416  } 
    340417   
     
    400477                  diff.setPixel(x, y, qRgba(255,128,128,255)); 
    401478                  errorPixels++; 
     479                   
    402480                } 
    403481        pErrorPixels = ((float)errorPixels)/(im1.height()*im1.width()); 
     
    506584  for (int i=0; i < mPvsStatFrames; i++) { 
    507585        float err; 
     586        // set frame id for saving the error buffer 
     587        mFrame = i; 
    508588        RandomViewPoint(); 
     589 
     590        // atlanta problematic frames: 325 525 691 1543 
     591#if 0 
     592        if (mFrame != 325 && 
     593                mFrame != 525 && 
     594                mFrame != 691 && 
     595                mFrame != 1543) 
     596          mPvsErrorBuffer[i] = -1; 
     597        else { 
     598          Debug<<"frame ="<<mFrame<<" vp="<<mViewPoint<<" vd="<<mViewDirection<<endl; 
     599        } 
     600#endif 
    509601        if (mPvsErrorBuffer[i] > 0.0f) { 
    510602          mPvsErrorBuffer[i] = GetPixelError(); 
     
    592684GlRendererWidget::paintGL() 
    593685{ 
    594         RenderErrors(); 
    595          
    596         mFrame++; 
     686  RenderErrors(); 
     687  RenderInfo(); 
     688  mFrame++; 
    597689} 
    598690 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h

    r572 r576  
    7272   
    7373bool mDetectEmptyViewSpace; 
     74  bool mSnapErrorFrames; 
     75  QString mSnapPrefix; 
    7476 
    7577  KdTree *mKdTree; 
     
    9698  RenderScene(); 
    9799 
     100 
    98101  void 
    99102  SetupProjection(const int w, const int h); 
     
    101104   
    102105   
    103   float 
    104   GetPixelError(); 
    105106 
    106107  void InitGL(); 
     
    159160  int ComputePvs() const; 
    160161 
     162  float 
     163  GetPixelError(); 
    161164 
    162165  int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 
     
    217220  RenderErrors(); 
    218221 
     222  void 
     223  RenderInfo(); 
     224 
    219225  virtual int GetWidth() const { return width(); } 
    220226  virtual int GetHeight() const { return height(); } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r575 r576  
    435435{ 
    436436  Vector3 origin, direction;  
    437  
    438   for (int i=0; rays.size() < number; i++) { 
    439         mViewCellsManager->GetViewPoint(origin); 
    440          
     437  int startSize = rays.size(); 
     438  for (int i=0; rays.size() - startSize  < number; i++) { 
    441439        // now get the direction 
    442440        switch (sampleType) { 
    443441        case OBJECT_BASED_DISTRIBUTION: { 
     442          mViewCellsManager->GetViewPoint(origin); 
    444443          Vector3 point; 
    445444          Vector3 normal; 
     
    450449        } 
    451450          break; 
     451        case OBJECT_DIRECTION_BASED_DISTRIBUTION: { 
     452          int i = RandomValue(0, mObjects.size() - 1); 
     453          Intersectable *object = mObjects[i]; 
     454          Vector3 normal; 
     455          object->GetRandomSurfacePoint(origin, normal); 
     456          direction = UniformRandomVector(normal); 
     457          origin += 0.1f*direction; 
     458        } 
     459          break; 
    452460        case DIRECTION_BASED_DISTRIBUTION: 
     461          mViewCellsManager->GetViewPoint(origin); 
    453462          direction = UniformRandomVector(); 
    454463          break; 
    455464        case DIRECTION_BOX_BASED_DISTRIBUTION: { 
     465          mViewCellsManager->GetViewPoint(origin); 
    456466          float alpha = RandomValue(0.0f, 2*M_PI); 
    457467          float beta = RandomValue(-M_PI/2, M_PI/2); 
     
    460470        } 
    461471        case SPATIAL_BOX_BASED_DISTRIBUTION: 
     472          mViewCellsManager->GetViewPoint(origin); 
    462473          direction = mKdTree->GetBox().GetRandomPoint() - origin; 
    463474          break; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r575 r576  
    108108        RSS_BASED_DISTRIBUTION, 
    109109        RSS_SILHOUETTE_BASED_DISTRIBUTION, 
    110         VSS_BASED_DISTRIBUTION 
     110        VSS_BASED_DISTRIBUTION, 
     111        OBJECT_DIRECTION_BASED_DISTRIBUTION 
    111112  }; 
    112113   
  • trunk/VUT/GtpVisibilityPreprocessor/src/PreprocessorThread.cpp

    r556 r576  
    2828 
    2929  if (0) { 
    30     camera.LookAtBox(mPreprocessor->mKdTree->GetBox()); 
     30    // camera.LookAtBox(mPreprocessor->mKdTree->GetBox()); 
    3131        //      camera.LookInBox(mPreprocessor->mKdTree->GetBox()); 
    32         //      camera.SetPosition(camera.mPosition + Vector3(0,300,0)); 
     32        camera.SetPosition(Vector3(3473, 6.778, -1699)); 
     33        camera.SetDirection(Vector3(-0.2432, 0, 0.97)); 
    3334    camera.SnapImage("camera.jpg", mPreprocessor->mKdTree, mPreprocessor->mSceneGraph); 
    3435  } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r574 r576  
    195195          vssRays.push_back(vssRay); 
    196196          hits ++; 
     197 
    197198        } 
    198199         
     
    209210        } 
    210211  } 
    211          
     212   
    212213  return hits; 
    213214} 
    214215 
    215216 
     217void 
     218RssPreprocessor::ExportObjectRays(VssRayContainer &rays, 
     219                                                                  const int objectId) 
     220{ 
     221  ObjectContainer::const_iterator oi; 
     222 
     223  Intersectable *object = NULL; 
     224  for (oi = mObjects.begin(); oi != mObjects.end(); ++oi) 
     225        if (objectId == (*oi)->GetId()) { 
     226          object = *oi; 
     227          break; 
     228        } 
     229 
     230  if (object == NULL) 
     231        return; 
     232   
     233  VssRayContainer selectedRays; 
     234  VssRayContainer::const_iterator it= rays.begin(), it_end = rays.end(); 
     235 
     236   
     237  for (; it != it_end; ++it) { 
     238        if ((*it)->mTerminationObject == object) 
     239          selectedRays.push_back(*it); 
     240  } 
     241   
     242 
     243  Exporter *exporter = Exporter::GetExporter("object-rays.x3d"); 
     244  //    exporter->SetWireframe(); 
     245  //    exporter->ExportKdTree(*mKdTree); 
     246  exporter->SetFilled(); 
     247  exporter->ExportIntersectable(object); 
     248  exporter->ExportRays(selectedRays, RgbColor(1, 0, 0)); 
     249   
     250  delete exporter; 
     251   
     252} 
    216253 
    217254 
     
    461498        SimpleRayContainer rays; 
    462499 
    463         GenerateRays(mInitialSamples, SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
     500        GenerateRays(mInitialSamples/4, SPATIAL_BOX_BASED_DISTRIBUTION, rays); 
     501        GenerateRays(mInitialSamples/4, OBJECT_BASED_DISTRIBUTION, rays); 
     502        GenerateRays(mInitialSamples/4, DIRECTION_BASED_DISTRIBUTION, rays); 
     503        GenerateRays(mInitialSamples/4, OBJECT_DIRECTION_BASED_DISTRIBUTION, rays); 
    464504         
    465505        CastRays(rays, mVssRays); 
     506 
     507        ExportObjectRays(mVssRays, 1546); 
    466508  } 
    467509   
     
    551593          VssRayContainer tmpVssRays; 
    552594 
    553           float ratios[] = {1.0f,0,0}; 
     595          float ratios[] = {0.8f,0.1f,0.1f}; 
    554596 
    555597           
     
    633675          mViewCellsManager->PrintPvsStatistics(mStats); 
    634676        } 
    635          
     677 
     678        if (0 && mPass > 0) { 
     679          if (mUseImportanceSampling) 
     680                renderer->mSnapPrefix.sprintf("snap/i-%02d-", mPass); 
     681          else 
     682                renderer->mSnapPrefix.sprintf("snap/r-%02d-", mPass); 
     683          renderer->mSnapErrorFrames = true; 
     684        } 
     685 
    636686        ComputeRenderError(); 
    637687         
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.h

    r567 r576  
    8787                         ); 
    8888 
     89  void 
     90  ExportObjectRays(VssRayContainer &rays, 
     91                                   const int objectId); 
     92         
    8993  int 
    9094  GenerateImportanceRays(RssTree *vssTree, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SceneGraph.cpp

    r492 r576  
    6565    nodeStack.pop(); 
    6666                 
    67     ObjectContainer::const_iterator mi = node->mGeometry.begin(); 
    68     for (; mi != node->mGeometry.end(); mi++)  
    69       (*mi)->SetId(id++); 
     67    ObjectContainer::iterator mi = node->mGeometry.begin(); 
     68    for (; mi != node->mGeometry.end(); mi++) { 
     69          // $$ JB remove object id=2601 (for debugging purposes in atlanta scene) 
     70          if (1) //id != 2601) 
     71                (*mi)->SetId(id++); 
     72          else { 
     73                node->mGeometry.erase(mi); 
     74                --mi; 
     75                id++; 
     76          } 
     77        } 
    7078     
    7179    SceneGraphNodeContainer::iterator ni = node->mChildren.begin(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r574 r576  
    23032303                        if (entSide < 0)  
    23042304                        { 
    2305                                 node = in->GetBack(); 
    2306                                 // plane does not split ray => no far child 
    2307                                 if (extSide <= 0)  
    2308                                         continue; 
    2309  
    2310                                 farChild = in->GetFront(); // plane splits ray 
     2305                          node = in->GetBack(); 
     2306                          // plane does not split ray => no far child 
     2307                          if (extSide <= 0)  
     2308                                continue; 
     2309                           
     2310                          farChild = in->GetFront(); // plane splits ray 
    23112311                        }  
    23122312                        else if (entSide > 0) 
    23132313                        { 
    2314                                 node = in->GetFront(); 
    2315  
    2316                                 if (extSide >= 0) // plane does not split ray => no far child 
    2317                                         continue; 
     2314                          node = in->GetFront(); 
     2315 
     2316                          if (extSide >= 0) // plane does not split ray => no far child 
     2317                                continue; 
    23182318 
    23192319                                farChild = in->GetBack(); // plane splits ray 
     
    23642364        return hits; 
    23652365} 
     2366 
     2367 
     2368 
    23662369 
    23672370int VspBspTree::TreeDistance(BspNode *n1, BspNode *n2) const 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r569 r576  
    2727        detectEmptyViewSpace false 
    2828        pvsRenderErrorSamples 10000 
    29  
    3029} 
    3130 
     
    7372RssPreprocessor { 
    7473        samplesPerPass 500000 
    75         initialSamples 1000000 
    76         vssSamples 15000000 
     74        initialSamples 2000000 
     75        vssSamples 20000000 
    7776        vssSamplesPerPass 1000000 
    7877        useImportanceSampling true 
Note: See TracChangeset for help on using the changeset viewer.