Changeset 2738


Ignore:
Timestamp:
06/04/08 18:40:13 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh

    r2737 r2738  
    1414SCENE=../data/Arena/arena_trees.obj 
    1515#VIEWCELLS=../data/Arena/arena-high-lods-5000-viewcells.xml.gz 
    16 #SCENE=../data/vienna/vienna_cropped.obj 
     16#SCENE=../data/vienna/2vienna_cropped.obj 
    1717#SCENE=../data/roofs_new.obj 
    18 #SCENE=../data/vienna/city_full_hp.obj 
    19 SCENE=../data/vienna/vienna_rep.obj 
     18SCENE=../data/vienna/city_full_hp.obj 
     19#SCENE=../data/vienna/vienna_rep.obj 
    2020 
    2121#SCENE=../data/vienna/vienna_cropped.obj 
     
    2525 
    2626#LOG_PREFIX=../src/SG08/rebut-arena-pixel2 
    27 LOG_PREFIX=../src/SG08/test 
     27LOG_PREFIX=../src/SG08/test_jitter_0.1 
    2828 
    2929ENVIRONMENT=gvs.env 
     
    4343-gvs_initial_samples=16 \ 
    4444-gvs_max_viewcells=3 \ 
    45 -gvs_min_contribution=50 \ 
     45-gvs_min_contribution=200 \ 
    4646-gvs_per_viewcell=true \ 
     47-gvs_radius_of_influence=5.0 \ 
     48-gvs_use_deterministic_gvs- \ 
     49-gvs_initial_jitter=0.1 \ 
    4750-preprocessor_detect_empty_viewspace+ \ 
    4851-preprocessor_snap_error_frames+ \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r2731 r2738  
    13991399                 "5"); 
    14001400 
     1401        RegisterOption("GvsPreprocessor.initialJitter", 
     1402                                   optFloat, 
     1403                                   "gvs_initial_jitter=", 
     1404                                   "0.1"); 
     1405 
     1406        RegisterOption("GvsPreprocessor.radiusOfInfluence", 
     1407                                   optFloat, 
     1408                                   "gvs_radius_of_influence=", 
     1409                                   "5.0"); 
     1410 
     1411        RegisterOption("GvsPreprocessor.useDeterministicGvs", 
     1412                                   optBool, 
     1413                                   "gvs_use_deterministic_gvs", 
     1414                                   "false"); 
     1415 
     1416 
    14011417 
    14021418  /**********************************************************************/ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2736 r2738  
    19631963                                        mColors.push_back(RandomColor(0, 1)); 
    19641964                                } 
     1965 
    19651966                                color = mColors[kdint->mGenericIdx]; 
    19661967                        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2736 r2738  
    2525#define NOT_ACCOUNTED_OBJECT 0 
    2626#define ACCOUNTED_OBJECT 2 
    27 #define DETERMINISTIC_GVS 0 
     27 
    2828 
    2929static const float MIN_DIST = 0.001f; 
     
    3131static ObjectContainer myobjects; 
    3232static int sInvalidSamples = 0; 
     33 
     34 
    3335 
    3436/////////// 
     
    8789        Environment::GetSingleton()->GetBoolValue("ViewCells.useKdPvs", mUseKdPvs); 
    8890 
     91        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.initialJitter", mInitialJitter); 
     92        Environment::GetSingleton()->GetBoolValue("GvsPreprocessor.useDeterministicGvs", mUseDeterministicGvs); 
     93 
     94        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.radiusOfInfluence", mRadiusOfInfluence); 
    8995 
    9096        char gvsStatsLog[100]; 
     
    162168                                                                                const VssRay &oldRay) 
    163169{ 
    164         // the predicted hitpoint: we expect to hit the same mesh again 
     170        // the predicted hitpoint is the point where the ray would have intersected the hit triangle 
    165171        Vector3 predictedHit = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay); 
    166172 
     
    168174        float len = Magnitude(currentRay.mTermination - currentRay.mOrigin); 
    169175         
    170         // distance large => this is likely to be a discontinuity 
    171         if (!((predictedLen - len) > mThreshold)) 
     176        // discrepancy between predicted and actual hit point large => this is likely to be a discontinuity 
     177 
     178        // matt: problem: this does only find CLOSER discontinuities, but not discontinuities which are FARTHER away 
     179        if ((predictedLen - len) < mThreshold) 
     180        //if ((fabs(predictedLen - len) < mThreshold) 
    172181        // q: rather use relative distance? 
    173         //if ((predictedLen / len) > mThreshold) 
     182        //if ((predictedLen / len) < mThreshold) 
    174183                return 0; 
    175184 
     
    183192        reverseRays.clear(); 
    184193 
    185         if (DETERMINISTIC_GVS) 
     194        if (mUseDeterministicGvs) 
    186195        { 
    187196                VssRay *reverseRay =  
     
    395404        int castRays = 0; 
    396405 
    397         // cast reverse rays if necessary 
    398         castRays += CheckDiscontinuity(ray1, hitTriangle, oldRay); 
    399         castRays += CheckDiscontinuity(ray2, hitTriangle, oldRay); 
    400  
    401406        if (EqualVisibility(ray1, ray2) || (SqrMagnitude(p1 - p2) <= MIN_DIST)) 
    402         { 
    403407                return castRays; 
    404         } 
    405          
     408         
     409 
    406410        // the new subdivision point 
    407411        const Vector3 p = (p1 + p2) * 0.5f; 
     
    433437         
    434438        //newRay->mFlags |= VssRay::BorderSample; 
     439 
     440        // cast reverse rays if necessary 
     441        castRays += CheckDiscontinuity(ray2, hitTriangle, oldRay); 
    435442 
    436443        // subdivide further 
     
    495502        const int numRandomRays = 16 - (int)simpleRays.size(); 
    496503 
    497         if (!DETERMINISTIC_GVS) 
     504        if (!mUseDeterministicGvs) 
    498505        { 
    499506                if (0) 
     
    514521        generationTimer.Exit(); 
    515522 
     523 
    516524        ///////////////////// 
    517525        //-- cast rays to vertices and determine visibility 
     
    547555                        (*rit)->mFlags |= VssRay::BorderSample; 
    548556        } 
     557 
     558        for (size_t i = 0; i < vssRays.size(); ++ i) 
     559        { 
     560                // check for discontinuity and cast reverse rays if necessary 
     561                castRays += CheckDiscontinuity(*vssRays[i], hitTriangle, currentRay); 
     562        } 
     563         
    549564 
    550565    // recursivly subdivide each edge 
     
    578593                hitTriangle = static_cast<TriangleIntersectable *>(tObj)->GetItem(); 
    579594        else 
    580                 cout << "border sampling: " << Intersectable::GetTypeName(tObj) << " not yet implemented" << endl; 
     595                cout << "error: gvs sampling for " << Intersectable::GetTypeName(tObj) << " not implemented" << endl; 
    581596 
    582597        generationTimer.Entry(); 
     
    623638        const int numRandomRays = 16 - ((int)simpleRays.size() % 16); 
    624639 
    625         SimpleRay mainRay = SimpleRay(currentRay.GetOrigin(),  
    626                                                                   currentRay.GetNormalizedDir(),  
    627                                                                   SamplingStrategy::GVS, 1.0f); 
    628  
    629         GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0, 0.01f); 
    630         //GenerateRays(numRandomRays, *mDistribution, simpleRays, sInvalidSamples); 
     640                if (!mUseDeterministicGvs) 
     641        { 
     642                if (0) 
     643                { 
     644                        SimpleRay mainRay = SimpleRay(currentRay.GetOrigin(),  
     645                                                          currentRay.GetNormalizedDir(),  
     646                                                                                  SamplingStrategy::GVS,  
     647                                                                                  1.0f); 
     648                         
     649                        GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0, 0.01f); 
     650                } 
     651                else 
     652                        GenerateImportanceSamples(currentRay, hitTriangle, numRandomRays, simpleRays); 
     653        } 
     654        else 
     655                GenerateRays(numRandomRays, *mDistribution, simpleRays, sInvalidSamples); 
    631656 
    632657        generationTimer.Exit(); 
     658 
    633659 
    634660 
     
    660686        EnqueueRays(vssRays); 
    661687         
     688        for (size_t i = 0; i < vssRays.size(); ++ i) 
     689        { 
     690                // check for discontinuity and cast reverse rays if necessary 
     691                castRays += CheckDiscontinuity(*vssRays[i], hitTriangle, currentRay); 
     692        } 
     693 
    662694#if 0 
    663695         
     
    726758                                                                                SimpleRay &reverseRay) 
    727759{ 
    728         // get triangle occluding the path to the hit mesh 
     760        // optain triangle that occludes the path to the currently processed mesh 
    729761        Triangle3 occluder; 
    730762        Intersectable *tObj = currentRay.mTerminationObject; 
     
    749781        const Vector3 predicted = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay); 
    750782 
    751         Vector3 newDir, newOrigin; 
    752  
    753783        ////////////// 
    754784        //-- Construct the mutated ray with xnew, 
    755785        //-- dir = predicted(x)- pnew as direction vector 
    756786 
    757         newDir = predicted - newPoint; 
     787        Vector3 newDir = newDir = predicted - newPoint; 
    758788 
    759789        // take xnew, p = intersect(viewcell, line(pnew, predicted(x)) as origin ? 
    760790        // difficult to say!! 
    761791        const float offset = 0.5f; 
    762         newOrigin = newPoint - newDir * offset; 
     792        Vector3 newOrigin = newPoint - newDir * offset; 
    763793         
    764794 
     
    777807                // check if ray intersects view cell 
    778808                if (!mCurrentViewCell->CastRay(ray)) 
    779                         return NULL; 
     809                        return false; 
    780810 
    781811                Ray::Intersection &hit = ray.intersections[0]; 
     
    808838        else 
    809839        { 
    810                 GenerateRays(DETERMINISTIC_GVS ? numSamples : numSamples / 16, *mDistribution, simpleRays, sInvalidSamples); 
     840                GenerateRays(mUseDeterministicGvs ? numSamples : numSamples / 16, *mDistribution, simpleRays, sInvalidSamples); 
    811841        } 
    812842 
     
    819849        castTimer.Entry(); 
    820850 
    821         if (DETERMINISTIC_GVS) 
     851        if (mUseDeterministicGvs) 
    822852        { 
    823853                const bool castDoubleRays = !mPerViewCell; 
     
    829859        else 
    830860        { 
    831                 float scale = 0.1f; 
    832861                if (0) 
    833862                        // casting bundles of 4 rays generated from the simple rays 
    834863                        CastRayBundles4(simpleRays, vssRays); 
    835864                else 
    836                         CastRayBundles16(simpleRays, vssRays, scale); 
     865                        CastRayBundles16(simpleRays, vssRays, mInitialJitter); 
    837866        } 
    838867 
     
    879908                mRayQueue.pop(); 
    880909                 
    881                 if (1) 
     910                if (0) 
    882911                        castSamples += AdaptiveBorderSampling(*ray); 
    883912                else 
     
    15151544                        mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution; 
    15161545 
    1517                         if (mGvsStats.mPassContribution < 2000) 
     1546                        if (!mUseDeterministicGvs && (mGvsStats.mPassContribution < 2000)) 
    15181547                                mUseProbablyVisibleSampling = true; 
    15191548                         
     
    19351964 
    19361965        Vector2 vr2(rr[0], rr[1]); 
    1937         const float sigma = triangle.GetBoundingBox().Radius() * 5.0f; 
     1966        const float sigma = triangle.GetBoundingBox().Radius() * mRadiusOfInfluence; 
    19381967        Vector2 gaussvec2; 
    19391968 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2736 r2738  
    44#include <fstream> 
    55#include <stack> 
    6  
    76#include "Preprocessor.h" 
     7#include "FlexibleHeap.h" 
     8 
     9 
    810 
    911namespace GtpVisibilityPreprocessor { 
     
    9395 
    9496 
     97struct ProbablyVisibleTriangleContainer 
     98{ 
     99        KdNode *node; 
     100        ObjectContainer mTriangles; 
     101}; 
     102 
     103 
     104typedef FlexibleHeap<ProbablyVisibleTriangleContainer *> ProbablyVisibleTriangleQueue; 
     105 
     106 
     107 
    95108/** Sampling based visibility preprocessing. The implementation is  
    96109        based on heuristical sampling of view space. 
     
    336349 
    337350        bool mUseProbablyVisibleSampling; 
     351 
     352        float mInitialJitter; 
     353 
     354        bool mUseDeterministicGvs; 
     355 
     356        float mRadiusOfInfluence; 
    338357}; 
    339358 
    340 }; 
     359 
     360} 
    341361 
    342362#endif 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2737 r2738  
    382382                                //-- output computed pvs 
    383383 
    384                                 //mUseFalseColors = false; 
    385                                 mUseFalseColors = true; 
     384                                mUseFalseColors = false; 
     385                                //mUseFalseColors = true; 
    386386                                glPushAttrib(GL_CURRENT_BIT); 
    387387                                glColor3f(0, 1, 0); 
Note: See TracChangeset for help on using the changeset viewer.