Changeset 2687


Ignore:
Timestamp:
05/19/08 02:43:25 (16 years ago)
Author:
mattausch
Message:

gvs testing

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/gvs.env

    r2682 r2687  
    3636 
    3737        # internal: 0 intel: 1 2: havran 3: havran dyn 
    38         rayCastMethod 2 
     38        rayCastMethod 1 
    3939 
    4040        exportVisibility false 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna

    r2686 r2687  
    88 
    99 
    10 #SCENE=../data/vienna/vienna_cropped.obj 
    11 SCENE=../data/vienna/city_full.obj 
     10SCENE=../data/vienna/vienna_cropped.obj 
     11#SCENE=../data/vienna/city_full.obj 
    1212 
    1313VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh

    r2682 r2687  
    1111echo "starting $TARGET version" 
    1212 
    13 SCENE=../data/vienna/vienna_cropped.obj 
    14 #SCENE=../data/vienna/city_full.obj 
     13#SCENE=../data/vienna/vienna_cropped.obj 
     14SCENE=../data/vienna/city_full.obj 
    1515 
    1616VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz  
     17VIEWPOINTS=../data/vienna/testwalk.vp 
    1718 
    18 LOG_PREFIX=../src/SG08/rebut 
     19#LOG_PREFIX=../src/SG08/vienna_cropped_100c 
     20LOG_PREFIX=../src/SG08/city_full_100 
     21 
    1922ENVIRONMENT=gvs.env 
    2023 
     
    2730-scene_filename=$SCENE \ 
    2831-preprocessor=gvs \ 
     32-preprocessor_use_vbos- \ 
    2933-gvs_epsilon=0.0001 \ 
    30 -gvs_total_samples=100000 \ 
    31 -gvs_samples_per_pass=100000 \ 
     34-gvs_total_samples=1000000 \ 
     35-gvs_samples_per_pass=1000000 \ 
    3236-gvs_initial_samples=16 \ 
    33 -gvs_max_viewcells=1 \ 
    34 -gvs_min_contribution=50 \ 
     37-gvs_max_viewcells=20 \ 
     38-gvs_min_contribution=100 \ 
    3539-gvs_per_viewcell=true \ 
    3640-gvs_stats=$LOG_PREFIX-gvsStats.log \ 
     
    4145-preprocessor_visibility_file=$LOG_PREFIX-i-gvs-b1-n4l.xml \ 
    4246-preprocessor_stats=$LOG_PREFIX-i-gvs-b1-n4l.log \ 
     47-view_cells_random_viewpoint_list=$VIEWPOINTS \ 
    4348-preprocessor_histogram_file=$LOG_PREFIX-i-gvs-b1-n4f.hlog  
    4449 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r2686 r2687  
    19231923                                   "false"); 
    19241924         
     1925        RegisterOption("Preprocessor.useVbos", 
     1926                                   optBool, 
     1927                                   "preprocessor_use_vbos", 
     1928                                   "true"); 
     1929 
    19251930        RegisterOption("Preprocessor.quitOnFinish", 
    19261931                                   optBool, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2686 r2687  
    8383mData(NULL), 
    8484mIndices(NULL), 
    85 //mUseVbos(true), 
    86 mUseVbos(false), 
    8785mComputeGVS(false), 
    8886mCurrentFrame(100) 
     
    121119                mViewPoint = Vector3(1038.7f, 192.4f, -471.0f); 
    122120                mViewDirection = Vector3(-0.8f, 0.0f, -0.6f); 
     121 
     122                mViewPoint = Vector3(440.295, 196.959, -781.302); 
     123                mViewDirection = Vector3(-0.0566328, 0, -0.998395); 
    123124        } 
    124125 
     
    136137        //mUseGlLists = true; 
    137138        mUseGlLists = false; 
     139 
     140        bool mUseVbos; 
     141        Environment::GetSingleton()->GetBoolValue("Preprocessor.useVbos", mUseVbos); 
    138142 
    139143        if (mViewCellsManager->GetViewCellPointsList()->size()) 
     
    15901594        for (sit = viewPoints.begin(); sit != sit_end; ++ sit, ++ i)  
    15911595        { 
    1592                 if ((i % 100) == 99) 
    1593                         cout << "processed " << i << " view points " << endl; 
    1594  
    1595                 //cout << "\n\nvp: " << (*sit) << endl; 
    15961596                SimpleRay sray = *sit; 
     1597                 
    15971598                int pvsSize = -1; 
    15981599 
     
    16231624                // drop the first frame (for some reason, the first frame yields wrong pixel error) 
    16241625                 
    1625                 if (//(mFrame > 0) &&  
    1626                         (err >=  -1e-6f) && (err < (1.0f - 1e-6f)) && (pvsSize != 0))  
    1627                 { 
    1628                         if (err > mPvsStat.maxError) 
     1626                if (pvsSize != 0) 
     1627                { 
     1628                        // hack: test if error is suspiciously large 
     1629                        if ((err >=  -1e-6f) && (err < (1.0f - 1e-6f))) 
    16291630                        { 
    1630                                 mPvsStat.maxError = err; 
    1631                                 cout << "new max error: " << mPvsStat.maxError * GetWidth() * GetHeight()  << endl; 
     1631                                if (err > mPvsStat.maxError) 
     1632                                { 
     1633                                        mPvsStat.maxError = err; 
     1634                                        cout << "new max error: " << mPvsStat.maxError * GetWidth() * GetHeight()  << endl; 
     1635                                } 
     1636 
     1637                                mPvsStat.sumError += err; 
     1638                                mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
     1639 
     1640                                if (err == 0.0f) 
     1641                                        ++ mPvsStat.errorFreeFrames; 
     1642 
     1643                                // $$ JB 
     1644                                // moved it back here not to count frames with negative err (backfacing triangle) 
     1645                                ++ mPvsStat.frames; 
     1646 
     1647                                if ((mPvsStat.frames % 100) == 0) 
     1648                                        cout << "processed " << mPvsStat.frames << " valid view points " << endl; 
    16321649                        } 
    1633  
    1634                         mPvsStat.sumError += err; 
    1635                         mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize; 
    1636  
    1637                         if (err == 0.0f) 
    1638                                 ++ mPvsStat.errorFreeFrames; 
    1639  
    1640                         // $$ JB 
    1641                         // moved it back here not to count frames with negative err (backfacing triangle) 
    1642                         ++ mPvsStat.frames; 
    1643                 } 
    1644                 else 
    1645                 { 
    1646                         cerr << "warning: negative error " << err << " at pvs size " << pvsSize << endl; 
    1647                 } 
    1648  
     1650                        else 
     1651                        { 
     1652                                cerr << "warning: strange error (" << err << "), pvs size " << pvsSize << endl; 
     1653                        } 
     1654                } 
    16491655        } 
    16501656 
     
    17031709 
    17041710 
     1711        // backfacing polygon found -> not a valid viewspace sample 
    17051712        if (pixelCount > 0) 
    1706         { 
    1707                 return false; // backfacing polygon found -> not a valid viewspace sample 
    1708         } 
     1713                return false;  
     1714         
    17091715        return true; 
    17101716} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2686 r2687  
    174174void GvsPreprocessor::CountObject(Intersectable *triObj) 
    175175{ 
    176         if ((triObj->mCounter != (NOT_ACCOUNTED_OBJECT + 1)) && (triObj->mCounter != (ACCOUNTED_OBJECT + 1))) 
     176        if ((triObj->mCounter != (NOT_ACCOUNTED_OBJECT + 1)) &&  
     177                (triObj->mCounter != (ACCOUNTED_OBJECT + 1))) 
    177178        { 
    178179                ++ triObj->mCounter; 
     
    486487        //CLEAR_CONTAINER(invalidSamples); 
    487488         
    488         //cout << "cast rays: " << castRays << endl; 
     489        //cout << "here3 cast rays: " << castRays << endl; 
    489490        return castRays; 
    490491} 
     
    658659int GvsPreprocessor::ProcessQueue() 
    659660{ 
     661        ++ mGvsStats.mGvsPass; 
     662 
    660663        int castSamples = 0; 
    661         ++ mGvsStats.mGvsPass; 
    662664 
    663665        while (!mRayQueue.empty())//&& (mGvsStats.mTotalSamples + castSamples < mTotalSamples) ) 
    664         { 
     666        {//cout<<"r"; 
    665667                //cout << "queue size: " << mRayQueue.size() << endl; 
    666668                // handle next ray 
     
    671673 
    672674                castSamples += newSamples; 
    673                 //delete ray; 
     675                // note: don't have to delete because handled by ray pool 
    674676        } 
    675677 
     
    814816 
    815817                if (!mOnlyRandomSampling) 
    816                         newSamples += ProcessQueue(); 
    817                  
     818                { 
     819                        int samplesPerRun = ProcessQueue(); 
     820                        newSamples += samplesPerRun; 
     821                        //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " "; 
     822                } 
     823 
    818824                passSamples += newSamples; 
    819825        mGvsStats.mPerViewCellSamples += newSamples; 
     
    847853 
    848854 
    849 void GvsPreprocessor::CompileViewCellsList() 
    850 { 
     855void GvsPreprocessor::CompileViewCellsFromPointList() 
     856{ 
     857        ViewCell::NewMail(); 
     858 
    851859        // Receive list of view cells from view cells manager 
    852860        ViewCellPointsList *vcPoints = mViewCellsManager->GetViewCellPointsList(); 
    853          
    854         if (!vcPoints->empty()) 
    855         { 
    856                 cout << "processing view cell list" << endl; 
    857                  
    858                 vector<ViewCellPoints *>::const_iterator vit, vit_end = vcPoints->end(); 
    859  
    860                 for (vit = vcPoints->begin(); vit != vit_end; ++ vit) 
     861 
     862        vector<ViewCellPoints *>::const_iterator vit, vit_end = vcPoints->end(); 
     863 
     864        for (vit = vcPoints->begin(); vit != vit_end; ++ vit) 
     865        { 
     866                ViewCellPoints *vp = *vit; 
     867 
     868                if (vp->first) // view cell  specified 
    861869                { 
    862                         mViewCells.push_back((*vit)->first); 
    863  
    864                         if (mViewCells.size() >= mMaxViewCells) 
    865                                 break; 
     870                        ViewCell *viewCell = vp->first; 
     871 
     872                        if (!viewCell->Mailed()) 
     873                        { 
     874                                viewCell->Mail(); 
     875                                mViewCells.push_back(viewCell); 
     876 
     877                                if (mViewCells.size() >= mMaxViewCells) 
     878                                        break; 
     879                        } 
    866880                } 
     881                else // no view cell specified => compute view cells using view point 
     882                { 
     883                        SimpleRayContainer::const_iterator rit, rit_end = vp->second.end(); 
     884 
     885                        for (rit = vp->second.begin(); rit != rit_end; ++ rit) 
     886                        { 
     887                                SimpleRay ray = *rit; 
     888 
     889                                ViewCell *viewCell = mViewCellsManager->GetViewCell(ray.mOrigin); 
     890 
     891                                if (viewCell && !viewCell->Mailed()) 
     892                                { 
     893                                        viewCell->Mail(); 
     894                                        mViewCells.push_back(viewCell); 
     895 
     896                                        if (mViewCells.size() >= mMaxViewCells) 
     897                                                break; 
     898                                } 
     899                        } 
     900                } 
     901        } 
     902} 
     903 
     904 
     905void GvsPreprocessor::CompileViewCellsList() 
     906{ 
     907        if (!mViewCellsManager->GetViewCellPointsList()->empty()) 
     908        { 
     909                cout << "processing view point list" << endl; 
     910                CompileViewCellsFromPointList(); 
    867911        } 
    868912        else 
    869913        { 
     914                ViewCell::NewMail(); 
     915 
    870916                while ((int)mViewCells.size() < mMaxViewCells) 
    871917                { 
    872                         if (0) 
    873                         { 
    874                                 mViewCells.push_back(mViewCellsManager->GetViewCell((int)mViewCells.size())); 
    875                                 continue; 
    876                         } 
    877  
    878                         // HACK 
    879918                        const int tries = 10000; 
    880919                        int i = 0; 
     
    906945} 
    907946 
    908  
     947#if 0 
    909948void GvsPreprocessor::IntersectWithViewCell() 
    910949{ 
     
    955994                } 
    956995        } 
    957 } 
    958  
     996        cout << "added " << mTrianglePvs.size() << " triangles (" << mCurrentViewCell->GetPvs().GetSize() << " objects) by intersection" << endl; 
     997 
     998} 
     999 
     1000#else 
     1001 
     1002void GvsPreprocessor::IntersectWithViewCell() 
     1003{ 
     1004        //Intersectable::NewMail(); 
     1005        mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 
     1006        AxisAlignedBox3 box = mCurrentViewCell->GetMesh()->mBox; 
     1007 
     1008        // compute pvs kd nodes that intersect view cell 
     1009        ObjectContainer kdobjects; 
     1010        mKdTree->CollectKdObjects(box, kdobjects); 
     1011 
     1012        ObjectContainer pvsKdObjects; 
     1013 
     1014        ObjectContainer::const_iterator oit, oit_end = kdobjects.end(); 
     1015 
     1016        for (oit = kdobjects.begin(); oit != oit_end; ++ oit) 
     1017        { 
     1018        KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 
     1019         
     1020                myobjects.clear(); 
     1021                mKdTree->CollectObjects(kdInt->GetItem(), myobjects); 
     1022 
     1023                // account for kd object pvs 
     1024                bool addkdobj = false; 
     1025 
     1026                ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 
     1027 
     1028                for (oit = myobjects.begin(); oit != oit_end; ++ oit) 
     1029                { 
     1030                        TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 
     1031              
     1032                        // the triangle itself intersects => add object 
     1033                        if (box.Intersects(triObj->GetItem())) 
     1034                        { 
     1035                                if ((triObj->mCounter < ACCOUNTED_OBJECT)) 
     1036                                { 
     1037                                        triObj->mCounter += ACCOUNTED_OBJECT; 
     1038 
     1039                                        mTrianglePvs.push_back(triObj); 
     1040                                        mGenericStats = (int)mTrianglePvs.size(); 
     1041 
     1042                                        addkdobj = true; 
     1043                                } 
     1044                        } 
     1045                } 
     1046                 
     1047                // add node to object pvs 
     1048                if (addkdobj) 
     1049                        pvsKdObjects.push_back(kdInt); 
     1050        } 
     1051 
     1052        // new mail because objects were mailed for kd tree search 
     1053        KdNode::NewMail(); 
     1054 
     1055        // now actually ADD new objects to object pvs 
     1056        oit_end = pvsKdObjects.end(); 
     1057 
     1058        for (oit = pvsKdObjects.begin(); oit != oit_end; ++ oit) 
     1059        { 
     1060        KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 
     1061         
     1062                kdInt->Mail(); 
     1063 
     1064                mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 
     1065                if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt);   
     1066        } 
     1067 
     1068        cout << "added " << mTrianglePvs.size() << " triangles (" << (int)pvsKdObjects.size() << " objects) by intersection" << endl; 
     1069} 
     1070#endif 
    9591071 
    9601072void GvsPreprocessor::PerViewCellComputation() 
     
    11471259        } 
    11481260 
    1149         cout << "cast " << 2 * mGvsStats.mTotalSamples / (1e3f * TimeDiff(startTime, GetTime())) << "M rays/s" << endl; 
     1261        cout << "cast " << mGvsStats.mTotalSamples / (1e3f * TimeDiff(startTime, GetTime())) << "M single rays/s" << endl; 
    11501262 
    11511263        if (GVS_DEBUG) 
     
    12161328        app << "#Id\n" << mViewCellId << endl; 
    12171329        app << "#Time\n" << mTimePerViewCell << endl;; 
    1218         app << "#TrianglePvs\n" << mTrianglePvs << endl; 
     1330        app << "#TriaePvs\n" << mTrianglePvs << endl; 
    12191331        app << "#ObjectPvs\n" << mPerViewCellPvs << endl; 
    1220         app << "#PvsCost\n" << (int)mPvsCost << endl; 
     1332        app << "#UpdatedPvs\n" << (int)mPvsCost << endl; 
    12211333 
    12221334        app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2677 r2687  
    1313class TriangleIntersectable; 
    1414class KdIntersectable; 
     15 
    1516 
    1617/** View space partition statistics. 
     
    243244        void CountObject(Intersectable *triObj); 
    244245 
     246        void CompileViewCellsFromPointList(); 
     247 
    245248 
    246249        ////////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2685 r2687  
    11921192        else 
    11931193        { 
    1194                 cout << "setting ray pool size to samples per pass" << endl;        
    1195                 reserveRays = mSamplesPerPass * 2; 
     1194                const int n = 4; 
     1195                cout << "hack: setting ray pool size to multiple " << n << " of samples per pass" << endl;        
     1196                reserveRays = mSamplesPerPass * n; 
    11961197        } 
    11971198 
     
    12561257#if SHOW_RAYCAST_TIMING 
    12571258                if (castDoubleRays) 
    1258                         cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 
     1259                        cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M double rays/s" << endl; 
    12591260                else 
    1260                         cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 
     1261                        cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M single rays/s" << endl; 
    12611262#endif 
    12621263 
    12631264        } 
    1264         //cout << "numDummy: " << numTransformed << endl;        
    1265         //cerr<<"Determining PVS objects"<<endl; 
     1265 
    12661266        DeterminePvsObjects(vssRays); 
    1267         //      cerr<<"done."<<endl; 
    1268          
    12691267} 
    12701268 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2686 r2687  
    104104GlRendererBuffer(sceneGraph, viewcells, tree) 
    105105{ 
    106         mUseVbos = true; 
    107         //mUseVbos = false; 
    108          
    109106        //makeCurrent(); 
    110107        MakeLive(); 
     
    267264        pErrorPixels = (float)pixelCount / (GetWidth() * GetHeight()); 
    268265 
    269         const int pixelThres = 100000; 
     266        const int pixelThres = 0; 
    270267 
    271268        // some error happened 
     
    285282                        char filename[256]; 
    286283                        //sprintf(filename, "error-frame-%04d-%0.5f.png", mFrame, pErrorPixels); 
    287                         sprintf(filename, "error-frame-%04d-%08d.png", mFrame, pixelCount); 
     284                        sprintf(filename, "error-frame-%04d-%04d-%08d.png", mFrame, viewcell->GetId(), pixelCount); 
    288285                        QImage im = toImage(); 
    289286                        string str = mSnapPrefix + filename; 
     
    292289                        im.save(qstr, "PNG"); 
    293290 
    294  
     291#if 0 
    295292                        /////////// 
    296293                        //-- output computed pvs 
    297294 
    298                         mUseFalseColors = false; 
    299  
     295                        //mUseFalseColors = true; 
    300296                        glPushAttrib(GL_CURRENT_BIT); 
    301297                        glColor3f(0, 1, 0); 
     
    312308                        RenderPvs(pvs); 
    313309 
    314                         mUseForcedColors = false; 
    315  
     310                        //mUseForcedColors = false; 
    316311                        im = toImage(); 
    317312                        sprintf(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 
     
    321316 
    322317                        glPopAttrib(); 
     318#endif 
    323319                } 
    324320        } 
     
    575571        if (viewcell)  
    576572        { 
    577 #if 1 
    578573                // copy the pvs so that it can be filtered ... 
    579574                if (PvsChanged(viewcell))  
     
    607602                        mCurrentPvsCost = mPvsCache.mPvs.EvalPvsCost(); 
    608603                } 
    609 #else 
    610          
    611                 // update the indices for rendering 
    612                 PreparePvs(viewcell->GetPvs()); 
    613                 emit PvsUpdated(); 
    614  
    615 #endif 
    616604 
    617605                // Render PVS 
     
    643631        else  
    644632        { 
    645                 //OcclusionQuery *query = mOcclusionQueries[0]; 
    646                 //query->BeginQuery(); 
    647                  
    648633                RenderScene(); 
    649  
    650                 //query->EndQuery(); 
    651                 //int pixels = query->GetQueryResult(); 
    652                 //cout << " pixels: " << pixels; 
    653634        } 
    654635 
Note: See TracChangeset for help on using the changeset viewer.