Ignore:
Timestamp:
01/21/08 16:10:52 (17 years ago)
Author:
bittner
Message:

pixel error fix for renderer buffer

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2619 r2620  
    2626 
    2727// if 1 = SAFE RENDERING OF PVS primitives without VBOs for Pvs error estimation 
    28 #define EVAL_ERROR 1 
     28#define EVAL_ERROR 0 
    2929 
    3030namespace GtpVisibilityPreprocessor { 
     
    449449} 
    450450 
     451 
     452 
    451453void 
    452454GlRenderer::_RenderScene() 
     
    516518        for (; oi != mObjects.end(); oi++) { 
    517519 
    518                 if ((*oi)->Type() == Intersectable::TRIANGLE_INTERSECTABLE) { 
     520          if ((*oi)->Type() == Intersectable::TRIANGLE_INTERSECTABLE) { 
    519521                        TriangleIntersectable *object = (TriangleIntersectable *)*oi; 
    520522                        Triangle3 *t = &(object->GetItem()); 
     
    525527                        glVertex3f(t->mVertices[1].x, t->mVertices[1].y, t->mVertices[1].z); 
    526528                        glVertex3f(t->mVertices[2].x, t->mVertices[2].y, t->mVertices[2].z); 
    527  
    528                 } 
     529          } 
    529530        } 
    530531 
     
    834835GlRenderer::RenderKdNode(KdNode *node) 
    835836{ 
    836         if (node->IsLeaf())  
     837  if (node->IsLeaf())  
    837838        { 
    838839#if !EVAL_ERROR 
     
    843844                  { 
    844845                        RenderIntersectable(leaf->mObjects[i]); 
     846                         
    845847                  } 
    846848#endif 
     
    15771579                  // compute the pixel error 
    15781580                  float error = GetPixelError(pvsSize); 
    1579  
     1581                   
    15801582                  mPvsErrorBuffer[i].mError = error; 
    15811583                  mPvsErrorBuffer[i].mPvsSize = pvsSize; 
     
    16851687void GlRenderer::EnableDrawArrays() 
    16861688{ 
    1687         glEnableClientState(GL_VERTEX_ARRAY); 
    1688         glEnableClientState(GL_NORMAL_ARRAY); 
     1689  glEnableClientState(GL_VERTEX_ARRAY); 
     1690  glEnableClientState(GL_NORMAL_ARRAY); 
    16891691} 
    16901692 
     
    17711773#endif 
    17721774 
     1775 
     1776 
     1777void GlRenderer::PreparePvs(const ObjectPvs &pvs) 
     1778{ 
     1779        int indexBufferSize = 0; 
     1780         
     1781        KdNode::NewMail(); 
     1782        //Intersectable::NewMail(); 
     1783 
     1784         
     1785        ObjectPvsIterator it = pvs.GetIterator(); 
     1786 
     1787        while (it.HasMoreEntries())  
     1788        { 
     1789                Intersectable *obj = it.Next(); 
     1790                switch (obj->Type()) 
     1791                { 
     1792                case Intersectable::KD_INTERSECTABLE: 
     1793                        { 
     1794                                KdNode *node = static_cast<KdIntersectable *>(obj)->GetItem(); 
     1795                                _UpdatePvsIndices(node, indexBufferSize); 
     1796                        } 
     1797                        break; 
     1798                         
     1799                } 
     1800        } 
     1801 
     1802        mIndexBufferSize = indexBufferSize; 
     1803} 
     1804 
     1805void GlRenderer::_UpdatePvsIndices(KdNode *node, int &indexBufferSize) 
     1806{ 
     1807        if (node->Mailed()) 
     1808                return; 
     1809 
     1810        node->Mail(); 
     1811 
     1812        // if (mObjects.size() * 3 < indexBufferSize) cerr << "problem: " << mObjects.size() * 3 << " < " << indexBufferSize << endl; 
     1813        if (!node->IsLeaf())  
     1814        { 
     1815                KdInterior *kdInterior = static_cast<KdInterior *>(node); 
     1816 
     1817                _UpdatePvsIndices(kdInterior->mBack, indexBufferSize); 
     1818                _UpdatePvsIndices(kdInterior->mFront, indexBufferSize); 
     1819        }  
     1820        else  
     1821        { 
     1822                KdLeaf *leaf = static_cast<KdLeaf *>(node); 
     1823 
     1824                leaf->mIndexBufferStart = indexBufferSize; 
     1825 
     1826                for (size_t i = 0; i < leaf->mObjects.size(); ++ i) 
     1827                { 
     1828                        TriangleIntersectable *obj =  
     1829                                static_cast<TriangleIntersectable *>(leaf->mObjects[i]); 
     1830 
     1831                        if (obj->mRenderedFrame != mCurrentFrame) 
     1832                        { 
     1833                                obj->mRenderedFrame = mCurrentFrame; 
     1834 
     1835                                mIndices[indexBufferSize + 0] = (obj->GetId() - 1) * 3 + 0; 
     1836                                mIndices[indexBufferSize + 1] = (obj->GetId() - 1) * 3 + 1; 
     1837                                mIndices[indexBufferSize + 2] = (obj->GetId() - 1) * 3 + 2; 
     1838 
     1839                                indexBufferSize += 3; 
     1840                        } 
     1841                } 
     1842 
     1843                leaf->mIndexBufferSize = indexBufferSize - leaf->mIndexBufferStart; 
     1844        } 
     1845 
     1846        //cout << "id: " << indexBufferSize << endl; 
     1847} 
    17731848 
    17741849void GlRenderer::CreateVertexArrays(SceneGraphLeaf *leaf) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r2615 r2620  
    174174  EvalPvsStat(); 
    175175 
     176  void PreparePvs(const ObjectPvs &pvs); 
     177  void _UpdatePvsIndices(KdNode *node, int &indexBufferSize); 
     178 
     179         
    176180  virtual void EvalPvsStat(const SimpleRayContainer &viewPoints); 
    177181 
     
    211215 
    212216        PvsRenderStatistics mPvsStat; 
     217 
     218        unsigned int mIndexBufferSize; 
    213219 
    214220        int mPvsStatFrames; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r2617 r2620  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: ne 20. I 00:39:42 2008 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: po 21. I 14:57:24 2008 
    44# Project:  preprocessor.pro 
    55# Template: app 
     
    6363        $(MAKE) -f $(MAKEFILE).Debug uninstall 
    6464 
    65 Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 
     65Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc.net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 
    6666                C:\Qt\4.1.2\mkspecs\features\qt_config.prf \ 
    6767                C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2619 r2620  
    2121#define USE_CG 1 
    2222 
    23 #define TEST_PVS_RENDERING 1 
     23#define TEST_PVS_RENDERING 0 
    2424 
    2525#if USE_CG 
     
    9191  GlRendererBuffer(sceneGraph, viewcells, tree) 
    9292{ 
     93  mUseVbos = true; 
    9394  MakeCurrent(); 
    9495  InitGL(); 
     
    9697} 
    9798 
     99void 
     100QtGlRendererBuffer::RenderPvs(const ObjectPvs &pvs) 
     101{ 
     102#if TEST_PVS_RENDERING  
     103 
     104  // Render PVS 
     105  ObjectPvsIterator it = pvs.GetIterator(); 
     106   
     107  Intersectable::NewMail(); 
     108  mCurrentFrame++; 
     109  while (it.HasMoreEntries())  
     110        { 
     111          RenderIntersectable(it.Next()); 
     112        } 
     113 
     114#else 
     115   
     116  PreparePvs(pvs); 
     117 
     118  int offset = (int)mObjects.size() * 3; 
     119  char *arrayPtr = mUseVbos ? NULL : (char *)mData; 
     120 
     121  glVertexPointer(3, GL_FLOAT, 0, (char *)arrayPtr); 
     122  glNormalPointer(GL_FLOAT, 0, (char *)arrayPtr + offset * sizeof(Vector3)); 
     123  glDrawElements(GL_TRIANGLES, mIndexBufferSize, GL_UNSIGNED_INT, mIndices); 
     124   
     125#endif 
     126} 
    98127 
    99128// reimplemented here so that we can snap the error windows 
     
    133162        glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);  
    134163 
    135          
    136         // Render PVS 
    137         ObjectPvsIterator it = pvs.GetIterator(); 
    138164 
    139165        pvsSize = pvs.GetSize(); 
    140166        cout<<pvsSize<<endl; 
    141  
    142         Intersectable::NewMail(); 
    143         mCurrentFrame++; 
    144         while (it.HasMoreEntries())  
    145           { 
    146                 RenderIntersectable(it.Next()); 
    147           } 
    148  
     167         
     168        RenderPvs(pvs); 
     169         
    149170        //glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 
    150171        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     
    212233          glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    213234           
    214           // Render PVS 
    215           Intersectable::NewMail(); 
    216           mCurrentFrame++; 
    217            
    218            
    219           ObjectPvsIterator it = pvs.GetIterator(); 
    220           for (; it.HasMoreEntries(); )  
    221                 { 
    222                   RenderIntersectable(it.Next()); 
    223                 } 
     235          RenderPvs(pvs); 
    224236 
    225237          mUseForcedColors = false; 
     
    464476 
    465477 
    466 void QtGlRendererWidget::_UpdatePvsIndices(KdNode *node, int &indexBufferSize) 
    467 { 
    468         if (node->Mailed()) 
    469                 return; 
    470  
    471         node->Mail(); 
    472  
    473         // if (mObjects.size() * 3 < indexBufferSize) cerr << "problem: " << mObjects.size() * 3 << " < " << indexBufferSize << endl; 
    474         if (!node->IsLeaf())  
    475         { 
    476                 KdInterior *kdInterior = static_cast<KdInterior *>(node); 
    477  
    478                 _UpdatePvsIndices(kdInterior->mBack, indexBufferSize); 
    479                 _UpdatePvsIndices(kdInterior->mFront, indexBufferSize); 
    480         }  
    481         else  
    482         { 
    483                 KdLeaf *leaf = static_cast<KdLeaf *>(node); 
    484  
    485                 leaf->mIndexBufferStart = indexBufferSize; 
    486  
    487                 for (size_t i = 0; i < leaf->mObjects.size(); ++ i) 
    488                 { 
    489                         TriangleIntersectable *obj =  
    490                                 static_cast<TriangleIntersectable *>(leaf->mObjects[i]); 
    491  
    492                         if (obj->mRenderedFrame != mCurrentFrame) 
    493                         { 
    494                                 obj->mRenderedFrame = mCurrentFrame; 
    495  
    496                                 mIndices[indexBufferSize + 0] = (obj->GetId() - 1) * 3 + 0; 
    497                                 mIndices[indexBufferSize + 1] = (obj->GetId() - 1) * 3 + 1; 
    498                                 mIndices[indexBufferSize + 2] = (obj->GetId() - 1) * 3 + 2; 
    499  
    500                                 indexBufferSize += 3; 
    501                         } 
    502                 } 
    503  
    504                 leaf->mIndexBufferSize = indexBufferSize - leaf->mIndexBufferStart; 
    505         } 
    506  
    507         //cout << "id: " << indexBufferSize << endl; 
    508 } 
    509478 
    510479 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2615 r2620  
    6666 
    6767  int ComputePvs() const { return 0; } 
    68    
     68 
     69  void 
     70  RenderPvs(const ObjectPvs &pvs); 
     71 
    6972  float 
    7073  GetPixelError(int &pvsSize); 
     
    216219        float mTransferFunction; 
    217220 
    218         unsigned int mIndexBufferSize; 
    219221 
    220222        Vector3 mDummyViewPoint; 
     
    543545        void _RenderColoredPvs(); 
    544546 
    545         void _UpdatePvsIndices(KdNode *node, int &indexBufferSize); 
     547  //    void _UpdatePvsIndices(KdNode *node, int &indexBufferSize); 
    546548 
    547549        float ComputeRenderCost(ViewCell *vc); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SG08/run_test_pixel

    r2619 r2620  
    44#COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+" 
    55#COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -samples_per_pass=500000 -samples_per_evaluation=10000000 -total_samples=500000000 -preprocessor_pvs_rendererror_samples=10000 -preprocessor_evaluatePixelError+" 
    6 COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer+ -preprocessor_evaluate_filter- -samples_per_pass=500000 -samples_per_evaluation=100000 -total_samples=500000000 -preprocessor_pvs_rendererror_samples=100 -preprocessor_evaluatePixelError+ -preprocessor_detect_empty_viewspace+ -kd_pvs_area=1e-5 -view_cells_use_kd_pvs+ -af_use_kd_pvs+" 
    7  
     6COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -samples_per_pass=1000000 -samples_per_evaluation=10000000 -total_samples=250000000 -preprocessor_pvs_rendererror_samples=1000 -preprocessor_evaluatePixelError+ -preprocessor_detect_empty_viewspace+ -kd_pvs_area=1e-5 -view_cells_use_kd_pvs+ -af_use_kd_pvs+" 
     7  
    88#SCENE="../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d" 
    99#VIEWCELLS=../data/vienna/vienna-viewcells-5000.xml 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SG08/run_test_vienna

    r2607 r2620  
    55#COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -preprocessor_detect_empty_viewspace- -total_samples=500000000" 
    66 
    7 COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -preprocessor_detect_empty_viewspace+ -samples_per_evaluation=5000000 -samples_per_pass=1000000 -total_samples=1000000000 -view_cells_use_kd_pvs+" 
     7COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer- -preprocessor_evaluate_filter- -preprocessor_detect_empty_viewspace+ -samples_per_evaluation=5000000 -samples_per_pass=1000000 -total_samples=12000000 -view_cells_use_kd_pvs+ -preprocessor_ray_cast_method=0" 
    88 
    99 
     
    1313 
    1414 
    15 PREFIX=../work/plots/osp-vienna-SG08 
     15PREFIX=../work/plots/osp-vienna-SG08-gr 
    1616 
    1717 
     
    1919###################### 
    2020 
    21 # # $COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    22 # # -preprocessor_visibility_file=$PREFIX-reference.xml \ 
    23 # # -view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \ 
    24 # # -preprocessor_histogram_file=$PREFIX-r-reference.hlog 
    25  
    26 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    27 # -rss_distributions=direction -view_cells_filter_max_size=1 \ 
    28 # -preprocessor_visibility_file=$PREFIX-r-reference-global.xml \ 
    29 # -preprocessor_stats=$PREFIX-reference-global.log \ 
    30 # -preprocessor_histogram_file=$PREFIX-r-reference-global.hlog 
     21$COMMAND -preprocessor=sampling -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     22-preprocessor_visibility_file=$PREFIX-reference.xml \ 
     23-view_cells_filter_max_size=1 -preprocessor_stats=$PREFIX-r-reference.log \ 
     24-preprocessor_histogram_file=$PREFIX-r-reference.hlog 
     25 
     26$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     27 -rss_distributions=direction -view_cells_filter_max_size=1 \ 
     28 -preprocessor_visibility_file=$PREFIX-r-reference-global.xml \ 
     29 -preprocessor_stats=$PREFIX-reference-global.log \ 
     30 -preprocessor_histogram_file=$PREFIX-r-reference-global.hlog 
    3131 
    3232# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     
    286286# -preprocessor_stats=$PREFIX-combined-m8-1.log  
    287287 
    288 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    289 -mutation_silhouette_prob=0.5 \ 
    290 -mutation_reverse_samples_distance=1.0 \ 
    291 -mutation_radius_origin=1.0 \ 
    292 -mutation_radius_termination=0.2 \ 
    293 -mutation_use_unsucc_count_importance+ \ 
    294 -mutation_use_pass_importance- \ 
    295 -mutation_buffer_size=2000000 \ 
    296 -rss_distributions=mutation+object_direction+spatial \ 
    297 -preprocessor_stats=$PREFIX-combined-m8-2.log  
     288# USE THIS ONE!!!!!! 
     289# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     290# -mutation_silhouette_prob=0.5 \ 
     291# -mutation_reverse_samples_distance=1.0 \ 
     292# -mutation_radius_origin=1.0 \ 
     293# -mutation_radius_termination=0.2 \ 
     294# -mutation_use_unsucc_count_importance+ \ 
     295# -mutation_use_pass_importance- \ 
     296# -mutation_buffer_size=2000000 \ 
     297# -rss_distributions=mutation+object_direction+spatial \ 
     298# -preprocessor_stats=$PREFIX-combined-m8-2.log  
    298299 
    299300# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     
    308309# -preprocessor_stats=$PREFIX-combined-m8-3.log  
    309310 
    310 $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    311 -mutation_silhouette_prob=0.5 \ 
    312 -mutation_reverse_samples_distance=1.0 \ 
    313 -mutation_radius_origin=0.5 \ 
    314 -mutation_radius_termination=0.2 \ 
    315 -mutation_use_unsucc_count_importance- \ 
    316 -mutation_use_pass_importance+ \ 
    317 -mutation_buffer_size=2000000 \ 
    318 -rss_distributions=mutation+object_direction+spatial \ 
    319 -preprocessor_stats=$PREFIX-combined-m8-4.log  
     311# $COMMAND -preprocessor=combined -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     312# -mutation_silhouette_prob=0.5 \ 
     313# -mutation_reverse_samples_distance=1.0 \ 
     314# -mutation_radius_origin=0.5 \ 
     315# -mutation_radius_termination=0.2 \ 
     316# -mutation_use_unsucc_count_importance- \ 
     317# -mutation_use_pass_importance+ \ 
     318# -mutation_buffer_size=2000000 \ 
     319# -rss_distributions=mutation+object_direction+spatial \ 
     320# -preprocessor_stats=$PREFIX-combined-m8-4.log  
Note: See TracChangeset for help on using the changeset viewer.