Changeset 2742


Ignore:
Timestamp:
06/06/08 17:40:59 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna

    r2725 r2742  
    88 
    99 
    10 #SCENE=../data/vienna/vienna_cropped.obj 
     10SCENE=../data/vienna/vienna_cropped.obj 
    1111#SCENE=../data/vienna/city_full.obj 
    12 SCENE=../data/vienna/city_full_hp.obj 
     12#SCENE=../data/vienna/city_full_hp.obj 
    1313#SCENE=../data/vienna/vienna_rep.obj 
    1414 
     
    4040 -preprocessor_detect_empty_viewspace+ \ 
    4141 -preprocessor_use_vbos- \ 
    42  -preprocessor_ray_cast_method=3 \ 
     42 -preprocessor_ray_cast_method=1 \ 
    4343 -view_cells_random_viewpoint_list=$VIEWPOINTS \ 
    4444 demo1.env 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh

    r2741 r2742  
    1717#SCENE=../data/roofs_new.obj 
    1818SCENE=../data/vienna/city_full_hp.obj 
    19 SCENE=../data/vienna/vienna_rep.obj 
    20 #SCENE=../data/vienna/vienna_cropped.obj 
     19#SCENE=../data/vienna/vienna_rep.obj 
     20SCENE=../data/vienna/vienna_cropped.obj 
    2121 
    2222VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz  
     
    4343-gvs_initial_samples=16 \ 
    4444-gvs_max_viewcells=1 \ 
    45 -gvs_min_contribution=50 \ 
     45-gvs_min_contribution=20 \ 
    4646-gvs_per_viewcell=true \ 
    4747-gvs_radius_of_influence=5.0 \ 
    48 -gvs_use_deterministic_gvs- \ 
     48-gvs_use_deterministic_gvs+ \ 
    4949-gvs_initial_jitter=0.1 \ 
    5050-preprocessor_detect_empty_viewspace+ \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2738 r2742  
    9797 
    9898                // for sg snapshot 
    99           mViewPoint = Vector3(32.8596, 9.86079, -1023.79); 
    100           mViewDirection = Vector3(-0.92196, 0, 0.387286); 
     99                mViewPoint = Vector3(32.8596, 9.86079, -1023.79); 
     100                mViewDirection = Vector3(-0.92196, 0, 0.387286); 
    101101 
    102102                // inside 
     
    106106                if (1) { 
    107107 
    108                 // outside 
    109                 mViewPoint = Vector3(35.092, 17.7078, -857.966); 
    110                 mViewDirection = Vector3(-0.411287, 0, -0.911506); 
    111  
    112                 // strange viewcell for error measurements (id 534) 
    113                 mViewPoint = Vector3(1405.9, 218.284, -736.785); 
    114                 mViewDirection = Vector3(0.989155, 0, 0.146877); 
    115  
    116                 // high error for city_full 
    117                 mViewPoint = Vector3(842.521, 194.708, -136.708); 
    118                 mViewDirection = Vector3(0.730514, 0, -0.682897); 
    119  
    120                 // also high error for city_full 
    121                 mViewPoint = Vector3(1038.7f, 192.4f, -471.0f); 
    122                 mViewDirection = Vector3(-0.8f, 0.0f, -0.6f); 
    123  
    124                 mViewPoint = Vector3(440.295, 196.959, -781.302); 
    125                 mViewDirection = Vector3(-0.0566328, 0, -0.998395); 
    126  
    127                 mViewPoint = Vector3(680.682, 189.552, -278.177); 
    128                 mViewDirection = Vector3(0.942709, -0, -0.333584); 
    129  
    130                 // strange error for gvs 
    131                 mViewPoint = Vector3(1186.9, 193.552, -377.044); 
    132                 mViewDirection = Vector3(-0.963031, -0, -0.269365); 
    133  
    134                 mViewPoint = Vector3(1189.54, 220.087, -462.869); 
    135                 mViewDirection = Vector3(-0.996972, -0, -0.0776569); 
    136  
    137                 mViewPoint = Vector3(1199.53, 257.677, -457.145); 
    138                 mViewDirection = Vector3(-0.71206, -0, -0.702108); 
    139  
    140                 mViewPoint = Vector3(1188.22, 187.427, -381.739); 
    141                 mViewDirection = Vector3(-0.963031, -0, -0.269365); 
     108                        // outside 
     109                        mViewPoint = Vector3(35.092, 17.7078, -857.966); 
     110                        mViewDirection = Vector3(-0.411287, 0, -0.911506); 
     111 
     112                        // strange viewcell for error measurements (id 534) 
     113                        mViewPoint = Vector3(1405.9, 218.284, -736.785); 
     114                        mViewDirection = Vector3(0.989155, 0, 0.146877); 
     115 
     116                        // high error for city_full 
     117                        mViewPoint = Vector3(842.521, 194.708, -136.708); 
     118                        mViewDirection = Vector3(0.730514, 0, -0.682897); 
     119 
     120                        // also high error for city_full 
     121                        mViewPoint = Vector3(1038.7f, 192.4f, -471.0f); 
     122                        mViewDirection = Vector3(-0.8f, 0.0f, -0.6f); 
     123 
     124                        mViewPoint = Vector3(440.295, 196.959, -781.302); 
     125                        mViewDirection = Vector3(-0.0566328, 0, -0.998395); 
     126 
     127                        mViewPoint = Vector3(680.682, 189.552, -278.177); 
     128                        mViewDirection = Vector3(0.942709, -0, -0.333584); 
     129 
     130                        // strange error for gvs 
     131                        /*mViewPoint = Vector3(1186.9, 193.552, -377.044); 
     132                        mViewDirection = Vector3(-0.963031, -0, -0.269365); 
     133 
     134                        mViewPoint = Vector3(1189.54, 220.087, -462.869); 
     135                        mViewDirection = Vector3(-0.996972, -0, -0.0776569); 
     136 
     137                        mViewPoint = Vector3(1199.53, 257.677, -457.145); 
     138                        mViewDirection = Vector3(-0.71206, -0, -0.702108); 
     139 
     140                        mViewPoint = Vector3(1188.22, 187.427, -381.739); 
     141                        mViewDirection = Vector3(-0.963031, -0, -0.269365); 
     142 
     143                        mViewPoint = Vector3(1188.22, 187.427, -381.739); 
     144                        mViewDirection = Vector3(-0.963031, -0, -0.269365); 
     145*/ 
    142146                } 
    143147        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2741 r2742  
    140140 
    141141                // note: deletion of the ray is handled by ray pool 
     142                mRayCaster->SheduleRayForDeletion(ray); 
    142143        } 
    143144} 
     
    209210 
    210211        mGvsStats.mReverseSamples += (int)reverseRays.size(); 
    211  
    212212        EnqueueRays(reverseRays); 
    213213 
     
    234234        simpleRays.clear(); 
    235235 
    236         CreateRandomizedReverseRays(currentRay, predictedHit, simpleRays, 16); 
     236        CreateRandomizedReverseRays(currentRay, predictedHit, simpleRays, 16, hitTriangle); 
    237237 
    238238        static VssRayContainer reverseRays; 
     
    344344bool GvsPreprocessor::HandleRay(VssRay *vssRay) 
    345345{ 
    346         if (!vssRay || !HasContribution(*vssRay)) 
     346        if (!vssRay) 
    347347                return false; 
    348348 
     349        if (!HasContribution(*vssRay)) 
     350        { 
     351                mRayCaster->SheduleRayForDeletion(vssRay); 
     352                return false; 
     353        } 
     354         
    349355        if (0 && GVS_DEBUG) 
    350356                mVssRays.push_back(new VssRay(*vssRay)); 
     
    354360 
    355361        ++ mGvsStats.mTotalContribution; 
     362 
     363        if (mRayQueue.size() % 10000 == 0) 
     364                cout << "ray queue size: " << mRayQueue.size() << endl; 
     365 
     366        if (mGvsStats.mTotalContribution % 10000 == 0) 
     367                cout << "contri: " << mGvsStats.mTotalContribution << endl; 
    356368 
    357369        return true; 
     
    452464        // cast single ray to check if a triangle was missed. note: not efficient!! 
    453465        newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell); 
     466        ++ castRays; 
     467         
    454468        castTimer.Exit(); 
    455469 
    456         ++ castRays; 
    457  
    458         // this ray will not be further processed 
    459         // note: ray deletion is handled by ray pool 
    460         if (!newRay) return castRays; 
    461  
    462         rayTimer.Entry(); 
    463  
    464         // new triangle discovered? => add new ray to queue 
    465         HandleRay(newRay); 
    466  
    467         rayTimer.Exit(); 
    468          
     470        if (!newRay) 
     471                return castRays; 
     472 
    469473        //newRay->mFlags |= VssRay::BorderSample; 
    470474 
    471475        // cast reverse rays if necessary 
    472         castRays += CheckDiscontinuity(ray2, hitTriangle, oldRay); 
    473  
     476        castRays += CheckDiscontinuity(*newRay, hitTriangle, oldRay); 
     477         
    474478        // subdivide further 
    475479        castRays += SubdivideEdge(hitTriangle, p1, p, ray1, *newRay, oldRay); 
    476480        castRays += SubdivideEdge(hitTriangle, p, p2, *newRay, ray2, oldRay); 
    477          
     481 
     482        rayTimer.Entry(); 
     483 
     484        // new triangle discovered? => add new ray to queue 
     485        HandleRay(newRay); 
     486 
     487        rayTimer.Exit(); 
     488 
    478489        return castRays; 
    479490} 
     
    549560        int castRays = (int)simpleRays.size(); 
    550561 
    551         // handle cast rays 
    552         EnqueueRays(vssRays); 
    553  
    554562        if (0) 
    555563        { 
     
    567575                        (*rit)->mFlags |= VssRay::BorderSample; 
    568576        } 
    569  
     577#if 0 
    570578    // recursivly subdivide each edge 
    571579        for (int i = 0; i < numBorderSamples; ++ i) 
     
    580588                                                                  currentRay); 
    581589        } 
    582          
     590#endif   
    583591        mGvsStats.mBorderSamples += castRays; 
    584592         
     593        // handle cast rays 
     594        EnqueueRays(vssRays); 
     595 
    585596        return castRays; 
    586597} 
     
    602613                cout << "error: gvs sampling for " << Intersectable::GetTypeName(tObj) << " not implemented" << endl; 
    603614 
     615         
     616        static SimpleRayContainer simpleRays; 
     617        simpleRays.clear(); 
     618         
     619 
    604620        generationTimer.Entry(); 
    605  
     621#if 0 
    606622        static VertexContainer enlargedTriangle; 
    607623        enlargedTriangle.clear(); 
     
    625641        } 
    626642 
    627         /// create rays from sample points and handle them 
    628         static SimpleRayContainer simpleRays; 
    629         simpleRays.clear(); 
    630          
    631643        VertexContainer::const_iterator vit, vit_end = subdivEnlargedTri.end(); 
    632644 
     
    639651        } 
    640652 
    641          
     653#endif   
    642654        ////////// 
    643655        //-- fill up simple rays with random rays so we can cast 16 rays at a time 
     
    675687        int castRays = (int)simpleRays.size(); 
    676688 
    677         // handle cast rays 
    678         EnqueueRays(vssRays); 
    679  
    680  
    681 #if 1 
     689#if 0 
    682690        for (size_t i = 0; i < vssRays.size(); ++ i) 
    683691        { 
     
    685693                castRays += CheckDiscontinuity2(*vssRays[i], hitTriangle, currentRay); 
    686694        } 
    687  
     695#endif 
     696#if 0 
    688697 
    689698    // recursivly subdivide each edge 
     
    702711 
    703712        mGvsStats.mBorderSamples += castRays; 
    704          
     713 
     714        // handle cast rays 
     715        EnqueueRays(vssRays); 
     716 
    705717        return castRays; 
    706718} 
     
    844856        else 
    845857        { 
    846                 GenerateRays(mUseDeterministicGvs ? numSamples : numSamples / 16, *mDistribution, simpleRays, sInvalidSamples); 
     858                GenerateRays(mUseDeterministicGvs ?  
     859                        numSamples : numSamples / 16, *mDistribution, simpleRays, sInvalidSamples); 
    847860        } 
    848861 
     
    883896 
    884897 
    885 void GvsPreprocessor::EnqueueRays(VssRayContainer &samples) 
     898void GvsPreprocessor::EnqueueRays(const VssRayContainer &samples) 
    886899{ 
    887900        rayTimer.Entry(); 
     
    893906                VssRay *ray = *vit; 
    894907                HandleRay(ray); 
    895                 // note: deletion of invalid samples handked by ray pool 
    896908        } 
    897909 
     
    918930                else 
    919931                        castSamples += AdaptiveBorderSamplingOpt(*ray); 
    920  
    921                 // note: don't have to delete because handled by ray pool 
    922932        } 
    923933 
     
    20012011void GvsPreprocessor::PrepareProbablyVisibleSampling() 
    20022012{ 
    2003          
    20042013        // warning: using mailing! 
    20052014        Intersectable::NewMail(); 
     
    20432052                                                                                                  const Vector3 &predictedPoint,  
    20442053                                                                                                  SimpleRayContainer &rays,  
    2045                                                                                                   int number) 
     2054                                                                                                  int number, 
     2055                                                                                                  const Triangle3 &triangle) 
    20462056{ 
    20472057        size_t currentNumber = rays.size(); 
     
    20522062        { 
    20532063                SimpleRay simpleRay; 
    2054                 if (CreateRandomizedReverseRay(ray, predictedPoint, simpleRay)) 
     2064                if (CreateRandomizedReverseRay(ray, predictedPoint, simpleRay, triangle)) 
    20552065                        rays.push_back(simpleRay); 
    20562066        } 
    20572067 
     2068        if (rays.size() != 16) 
     2069                cout << "x"; 
     2070        //else cout <<"y"; 
    20582071        //cout << "generated " << rays.size() << " rays" << endl; 
    20592072} 
     
    20622075bool GvsPreprocessor::CreateRandomizedReverseRay(const VssRay &ray,  
    20632076                                                                                                 const Vector3 &predictedPoint,  
    2064                                                                                                  SimpleRay &simpleRay) 
    2065 { 
    2066         //Vector3 nd = ray.GetNormalizedDir(); 
     2077                                                                                                 SimpleRay &simpleRay, 
     2078                                                                                                 const Triangle3 &triangle) 
     2079{ 
     2080        /*Vector3 nd = ray.GetNormalizedDir(); 
    20672081        const AxisAlignedBox3 box = mCurrentViewCell->GetBox(); 
    20682082        //Vector3 nd = box.GetNearestFace(origin).GetNormal(); 
     
    20702084 
    20712085        // Compute right handed coordinate system from direction 
    2072         /*Vector3 U, V; 
     2086        Vector3 U, V; 
    20732087        nd.RightHandedBase(U, V); 
    20742088         
     
    20792093 
    20802094        Vector2 vr2(rr[0], rr[1]); 
    2081         const float sigma = 1.0f;//triangle.GetBoundingBox().Radius() * mRadiusOfInfluence; 
     2095        const float sigma = triangle.GetBoundingBox().Radius() * 1.0f; 
    20822096        Vector2 gaussvec2; 
    20832097 
    20842098        GaussianOn2D(vr2, sigma, // input 
    20852099                         gaussvec2); // output 
    2086          
    2087         const Vector3 shift = gaussvec2.xx * U + gaussvec2.yy * V; 
    2088  
    2089         Vector3 newOrigin = ray.mOrigin + shift; 
    20902100        */ 
     2101        const Vector3 shift = 0;//gaussvec2.xx * U + gaussvec2.yy * V; 
     2102 
     2103        const Vector3 newTermination = ray.mTermination + shift; 
     2104         
    20912105        //cout << "o: " << origin << " new o: " << newOrigin << endl; 
    2092         Vector3 newOrigin = box.GetRandomPoint(); 
    2093         Vector3 direction = predictedPoint - newOrigin; 
     2106        Vector3 newOrigin = mCurrentViewCell->GetBox().GetRandomPoint(); 
     2107        Vector3 direction = newTermination - newOrigin; 
    20942108 
    20952109        const float len = Magnitude(direction); 
     
    21012115 
    21022116        if (0 && !IntersectsViewCell(newOrigin, -direction)) 
    2103         { 
    2104                 //cout << "x"; 
    21052117                return false; 
    2106         } 
    21072118 
    21082119        //cout << "y"; 
     
    21142125} 
    21152126 
    2116  
    2117 } 
     2127} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2741 r2742  
    178178                with respect to the previous ray. 
    179179        */ 
    180         void EnqueueRays(VssRayContainer &samples); 
     180        void EnqueueRays(const VssRayContainer &samples); 
    181181        /** Hepler function for adaptive border sampling. It finds  
    182182                new sample points around a triangle in a eps environment 
     
    300300                                             const Vector3 &predictedPoint,  
    301301                                                                         SimpleRayContainer &rays,  
    302                                                                          int number); 
     302                                                                         int number, 
     303                                                                         const Triangle3 &triangle); 
    303304 
    304305        bool CreateRandomizedReverseRay(const VssRay &ray,  
    305306                                            const Vector3 &predictedPoint, 
    306                                                                         SimpleRay &simpleray); 
     307                                                                        SimpleRay &simpleray, 
     308                                                                         const Triangle3 &triangle); 
    307309 
    308310        inline bool IntersectsViewCell(Vector3 &origin, const Vector3 &dir) const; 
     311 
     312        void DeleteOldRays(); 
     313 
    309314 
    310315 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2736 r2742  
    11821182                const int n = 4; 
    11831183                reserveRays = mSamplesPerPass * n; 
    1184                 cout << "setting ray pool size to " << reserveRays << endl;        
    1185  
    1186         } 
     1184 
     1185        } 
     1186 
     1187#ifdef USE_RAY_POOL 
     1188        cout << "setting ray pool size to " << reserveRays << endl;        
    11871189 
    11881190        cout << "======================" << endl; 
     
    11921194         
    11931195        cout<<"done."<<endl<<flush; 
    1194          
     1196#endif 
     1197 
    11951198        return true; 
    11961199} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r2718 r2742  
    373373                                                          const float pdf) 
    374374{ 
     375#ifdef USE_RAY_POOL 
     376 
    375377 #if DEBUG_RAYCAST 
    376378        Debug<<"PR2a"<<flush; 
     
    392394#endif 
    393395 
     396#else 
     397        VssRay *vssRay = new VssRay(origin, termination, originObject, terminationObject, pass, pdf); 
     398#endif 
    394399        return vssRay; 
    395400} 
     401 
     402 
     403void RayCaster::SheduleRayForDeletion(VssRay *ray) 
     404{ 
     405#ifndef USE_RAY_POOL 
     406        delete ray; 
     407#endif 
     408} 
     409 
     410 
     411/*void RayCaster::DeleteOldRays() 
     412{ 
     413        CLEAR_CONTAINER(mOldRays); 
     414}*/ 
    396415 
    397416 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h

    r2729 r2742  
    107107  { } 
    108108 
    109    
     109  void SheduleRayForDeletion(VssRay *ray); 
     110 
    110111  /*virtual void CastRaysEye4(SimpleRayContainer &rays, 
    111112    VssRayContainer &vssRays, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r2741 r2742  
    809809        static Vector3 point; 
    810810        static Vector3 normal; 
    811         static float r[2]; 
     811 
     812        float r[2]; 
    812813 
    813814        sHalton.GetNext(2, r); 
     
    831832                //origin = mViewCell->GetBox().GetRandomSurfacePoint(); 
    832833                origin = mViewCell->GetBox().GetRandomPoint(); 
    833  
     834//origin = Vector3(680.682, 189.552, -278.177); 
    834835                // move a little bit back to avoid piercing through walls 
    835836                // that bound the view cell 
Note: See TracChangeset for help on using the changeset viewer.