Changeset 572


Ignore:
Timestamp:
01/23/06 21:37:50 (18 years ago)
Author:
bittner
Message:

gl render error estimation changes for backface culling empty viewspace detection

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

Legend:

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

    r569 r572  
    4646  mFrame = 0; 
    4747  mWireFrame = false; 
     48  environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 
     49 
    4850} 
    4951 
     
    6971{ 
    7072 
    71   SetupFalseColor(object->mId); 
     73  glPushAttrib(GL_CURRENT_BIT); 
     74  if (mUseFalseColors) 
     75        SetupFalseColor(object->mId); 
     76   
    7277 
    7378  switch (object->Type()) { 
     
    8287        break; 
    8388  } 
     89 
     90  glPopAttrib(); 
    8491} 
    8592 
     
    8895GlRenderer::RenderViewCell(ViewCell *vc) 
    8996{ 
    90         if (vc->GetMesh()) 
    91                 RenderMesh(vc->GetMesh()); 
     97  if (vc->GetMesh()) { 
     98 
     99        if (vc->GetValid())  
     100          glColor3f(0,1,0); 
     101        else 
     102          glColor3f(0,0,1); 
     103         
     104        RenderMesh(vc->GetMesh()); 
     105  } 
    92106} 
    93107 
     
    117131  if (m) 
    118132        glColor3fv(&(m->mDiffuseColor.r)); 
    119   else 
    120         glColor3f(1.0f, 1.0f, 1.0f); 
    121133} 
    122134 
     
    194206GlRendererBuffer::RandomViewPoint() 
    195207{ 
    196   Vector3 pVector = Vector3(halton.GetNumber(1), 
    197                                                         halton.GetNumber(2), 
    198                                                         halton.GetNumber(3)); 
     208   
     209   
     210  // do not use this function since it could return different viewpoints for 
     211  // different executions of the algorithm 
     212 
     213  //mViewCellsManager->GetViewPoint(mViewPoint); 
     214 
     215  while (1) { 
     216        Vector3 pVector = Vector3(halton.GetNumber(1), 
     217                                                          halton.GetNumber(2), 
     218                                                          halton.GetNumber(3)); 
     219         
     220        mViewPoint =  mSceneGraph->GetBox().GetPoint(pVector); 
     221        ViewCell *v = mViewCellsManager->GetViewCell(mViewPoint); 
     222        if (v && v->GetValid()) 
     223          break; 
     224        // generate a new vector 
     225        halton.GenerateNext(); 
     226  } 
     227   
    199228   
    200229  Vector3 dVector = Vector3(2*M_PI*halton.GetNumber(4), 
    201230                                                        M_PI*halton.GetNumber(5), 
    202231                                                        0.0f); 
    203    
    204   mViewCellsManager->GetViewPoint(mViewPoint); 
    205  
    206   // mViewPoint =  mSceneGraph->GetBox().GetPoint(pVector); 
    207232   
    208233  mViewDirection = Normalize(Vector3(sin(dVector.x), 
     
    210235                                                                         0.0f, 
    211236                                                                         cos(dVector.x))); 
    212  
    213237  halton.GenerateNext(); 
    214238} 
     
    221245                                                                   KdTree *tree): 
    222246QGLPixelBuffer(QSize(w, h)), GlRenderer(sceneGraph, viewcells, tree) { 
     247  
    223248  
    224249 environment->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames); 
     
    238263   
    239264  mUseFalseColors = true; 
    240  
    241   SetupCamera(); 
    242   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    243   glEnable( GL_CULL_FACE ); 
    244    
    245   RenderScene(); 
    246  
    247   // now check whether any backfacing polygon would pass the depth test 
     265   
     266 
    248267  static int query = -1; 
     268  unsigned int pixelCount; 
     269 
    249270  if (query == -1) 
    250271        glGenOcclusionQueriesNV(1, (unsigned int *)&query); 
    251    
    252   glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 
    253   glDepthMask(GL_FALSE); 
    254   glDisable( GL_CULL_FACE ); 
    255    
    256   glBeginOcclusionQueryNV(query); 
    257    
    258   RenderScene(); 
    259    
    260   glEndOcclusionQueryNV(); 
    261  
    262   // at this point, if possible, go and do some other computation 
    263   glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    264   glDepthMask(GL_TRUE); 
    265   glEnable( GL_CULL_FACE ); 
    266    
    267   unsigned int pixelCount; 
    268   // reenable other state 
    269   glGetOcclusionQueryuivNV(query, 
    270                                                    GL_PIXEL_COUNT_NV, 
    271                                                    &pixelCount); 
    272  
    273   if (pixelCount > 0) 
    274         return -1.0f; // backfacing polygon found -> not a valid viewspace sample 
     272 
     273  if (mDetectEmptyViewSpace) { 
     274        // now check whether any backfacing polygon would pass the depth test 
     275        SetupCamera(); 
     276        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     277        glEnable( GL_CULL_FACE ); 
     278         
     279        RenderScene(); 
     280         
     281        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 
     282        glDepthMask(GL_FALSE); 
     283        glDisable( GL_CULL_FACE ); 
     284         
     285        glBeginOcclusionQueryNV(query); 
     286         
     287        RenderScene(); 
     288         
     289        glEndOcclusionQueryNV(); 
     290         
     291        // at this point, if possible, go and do some other computation 
     292        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     293        glDepthMask(GL_TRUE); 
     294        glEnable( GL_CULL_FACE ); 
     295         
     296        // reenable other state 
     297        glGetOcclusionQueryuivNV(query, 
     298                                                         GL_PIXEL_COUNT_NV, 
     299                                                         &pixelCount); 
     300         
     301        if (pixelCount > 0) 
     302          return -1.0f; // backfacing polygon found -> not a valid viewspace sample 
     303  } else 
     304        glDisable( GL_CULL_FACE ); 
     305         
    275306 
    276307  ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 
    277    
     308         
    278309  if (viewcell) { 
    279310        SetupCamera(); 
     
    323354  SetupCamera(); 
    324355  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    325   glEnable( GL_CULL_FACE ); 
    326    
     356 
     357 
     358  if (mDetectEmptyViewSpace)  
     359        glEnable( GL_CULL_FACE ); 
     360  else 
     361        glDisable( GL_CULL_FACE ); 
     362 
    327363  ObjectContainer::const_iterator oi = mObjects.begin(); 
    328364  for (; oi != mObjects.end(); oi++) 
     
    379415  // now render im1 
    380416  if (viewcell) { 
    381         if (mTopView) { 
     417        if (1 || mTopView) { 
    382418          mWireFrame = true; 
    383           RenderMeshInstance(viewcell); 
     419          RenderIntersectable(viewcell); 
    384420          mWireFrame = false; 
    385421        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h

    r563 r572  
    7070  int mFrame; 
    7171  bool mWireFrame; 
     72   
     73bool mDetectEmptyViewSpace; 
    7274 
    7375  KdTree *mKdTree; 
     
    164166  int mPvsStatFrames; 
    165167  vector<float> mPvsErrorBuffer; 
    166  
    167168private: 
    168169         
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r569 r572  
    437437        // load now because otherwise bounding box not correct 
    438438        mViewCellsManager->LoadViewCells(mViewCellsFilename, &mObjects); 
     439        // $$JB tmp make all viewcelss valid 
     440        mViewCellsManager->SetValidity(0, 9999999999);  
     441 
    439442  } 
    440443   
     
    515518        if (1)  
    516519          mViewCellsManager->Visualize(mObjects, selectedRays); 
     520 
     521        // viewcells->UpdatePVS(newVssRays); 
     522        Debug<<"Valid viewcells before set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
     523        // cull viewcells with PVS > median (0.5f) 
     524        mViewCellsManager->SetValidityPercentage(0, 0.5f);  
     525        Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    517526         
    518527        ComputeRenderError(); 
     
    547556  } 
    548557   
    549   // viewcells->UpdatePVS(newVssRays); 
    550   Debug<<"Valid viewcells before set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    551   // cull viewcells with PVS > median (0.5f) 
    552   mViewCellsManager->SetValidityPercentage(0, 0.5f);  
    553   Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    554558   
    555559  while (1) { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r571 r572  
    12681268  if (!mBspTree) 
    12691269        return NULL; 
     1270 
     1271  if (!mViewSpaceBox.IsInside(point)) 
     1272        return NULL; 
     1273 
    12701274  return mBspTree->GetViewCell(point); 
    12711275} 
     
    26142618        if (!mVspBspTree) 
    26152619                return NULL; 
     2620 
     2621        if (!mViewSpaceBox.IsInside(point)) 
     2622          return NULL; 
     2623 
    26162624        return mVspBspTree->GetViewCell(point); 
    26172625} 
Note: See TracChangeset for help on using the changeset viewer.