Changeset 534


Ignore:
Timestamp:
01/13/06 14:17:46 (18 years ago)
Author:
bittner
Message:

vss preprocessor void space identification fixed - by default it is off

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

Legend:

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

    r503 r534  
    279279                                float *tmax) const 
    280280{ 
     281  const float dirEps = 1e-8f; 
    281282  register float minx, maxx; 
    282283  ray.ComputeInvertedDir(); 
    283284   
    284   if (fabs(ray.dir.x) < 0.001) { 
     285  if (fabs(ray.dir.x) < dirEps) { 
    285286    if (mMin.x < ray.loc.x && mMax.x > ray.loc.x) { 
    286287      minx = -MAXFLOAT; 
     
    308309  *tmax = maxx; 
    309310   
    310   if (fabs(ray.dir.y) < 0.001) { 
     311  if (fabs(ray.dir.y) < dirEps) { 
    311312    if (mMin.y < ray.loc.y && mMax.y > ray.loc.y) { 
    312313      minx = -MAXFLOAT; 
     
    336337    *tmax = maxx; 
    337338   
    338   if (fabs(ray.dir.z) < 0.001) { 
     339  if (fabs(ray.dir.z) < dirEps) { 
    339340    if (mMin.z < ray.loc.z && mMax.z > ray.loc.z) { 
    340341      minx = -MAXFLOAT; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.h

    r492 r534  
    185185  Vector3 GetRandomPoint() const { 
    186186    Vector3 size = Size(); 
    187     return mMin + Vector3(RandomValue(0, size.x), 
    188                                                                                                         RandomValue(0, size.y), 
    189                                                                                                         RandomValue(0, size.z));  
     187    return mMin + Vector3(RandomValue(0.0f, size.x), 
     188                                                  RandomValue(0.0f, size.y), 
     189                                                  RandomValue(0.0f, size.z));  
    190190  } 
    191191 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp

    r531 r534  
    1515  // "back plane" 
    1616  mPlanes.push_back(Plane3(-VssRay::GetDirection(dCenter.x, dCenter.y), center)); 
    17  
     17   
    1818  Vector3 directions[4]; 
    1919  directions[0] = VssRay::GetDirection(dBox.Min().x, dBox.Min().y); 
     
    2323   
    2424  // side planes 
    25   mPlanes.push_back(Plane3(CrossProd(directions[0], directions[1]), center)); 
    26   mPlanes.push_back(Plane3(CrossProd(directions[1], directions[2]), center)); 
    27   mPlanes.push_back(Plane3(CrossProd(directions[2], directions[3]), center)); 
    28   mPlanes.push_back(Plane3(CrossProd(directions[3], directions[0]), center)); 
     25  mPlanes.push_back(Plane3(-CrossProd(directions[0], directions[1]), center)); 
     26  mPlanes.push_back(Plane3(-CrossProd(directions[1], directions[2]), center)); 
     27  mPlanes.push_back(Plane3(-CrossProd(directions[2], directions[3]), center)); 
     28  mPlanes.push_back(Plane3(-CrossProd(directions[3], directions[0]), center)); 
    2929 
    3030 
     
    122122 
    123123} 
     124 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r532 r534  
    14341434                                        "false"); 
    14351435 
     1436        RegisterOption("Preprocessor.detectEmptyViewSpace", 
     1437                                   optBool, 
     1438                                   "detectEmptyViewSpace", 
     1439                                   "false"); 
     1440         
     1441 
    14361442        /**************************************************************************************/ 
    14371443        /*                  View space partition KD tree related options                      */ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.cpp

    r492 r534  
    216216  // Watch for near-zero denominator 
    217217  // ONLY single sided polygons!!!!! 
    218   if (dot > -Limits::Small) 
    219     //  if (fabs(dot) < Limits::Small) 
    220     return Ray::NO_INTERSECTION; 
     218  if (ray.mFlags & Ray::CULL_BACKFACES) { 
     219        if (dot > -Limits::Small) 
     220          //  if (fabs(dot) < Limits::Small) 
     221          return Ray::NO_INTERSECTION; 
     222  } else { 
     223        if (fabs(dot) < Limits::Small) 
     224          return Ray::NO_INTERSECTION; 
     225  } 
    221226   
    222227  t = (-plane.mD - DotProd(plane.mNormal, ray.GetLoc())) / dot; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r532 r534  
    247247        mViewCellsManager->SetRenderer(mRenderSimulator); 
    248248 
     249         
    249250        //-- parse view cells construction method 
    250251        environment->GetBoolValue("ViewCells.loadFromFile", mLoadViewCells); 
     
    257258        if (mUseGlRenderer) 
    258259          renderer = new GlRendererBuffer(1024, 768, mSceneGraph, mViewCellsManager, mKdTree); 
    259          
     260 
     261 
     262        environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 
     263         
     264 
     265 
    260266        return true; 
    261267} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r520 r534  
    129129 
    130130  string mViewCellsFilename; 
    131  
     131   
     132  bool mDetectEmptyViewSpace; 
     133   
    132134protected: 
    133135 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h

    r475 r534  
    7171  vector<Intersectable *> testedObjects; 
    7272 
    73         // various flags 
    74         enum {STORE_KDLEAVES=1, STORE_BSP_INTERSECTIONS=2, STORE_TESTED_OBJECTS=4}; 
    75         int mFlags; 
     73  // various flags 
     74  enum {STORE_KDLEAVES=1, STORE_BSP_INTERSECTIONS=2, STORE_TESTED_OBJECTS=4, CULL_BACKFACES=8}; 
     75  int mFlags; 
    7676 
    7777         
     
    7979  Ray(const Vector3 &wherefrom, 
    8080      const Vector3 &whichdir, 
    81       const int _type):mFlags(0) { 
     81      const int _type):mFlags(CULL_BACKFACES) { 
    8282    loc = wherefrom; 
    8383    if (_type == LINE_SEGMENT) 
     
    9696  Ray(const VssRay &vssRay) { 
    9797        Init(vssRay); 
     98        mFlags |= CULL_BACKFACES; 
    9899  } 
    99100 
     
    301302struct SimpleRay 
    302303{ 
    303         Vector3 mOrigin; 
    304         Vector3 mDirection; 
    305         SimpleRay() {} 
    306         SimpleRay(const Vector3 &o, const Vector3 &d):mOrigin(o), mDirection(d) {} 
     304  Vector3 mOrigin; 
     305  Vector3 mDirection; 
     306  float mProbability; 
     307 
     308  SimpleRay() {} 
     309  SimpleRay(const Vector3 &o, const Vector3 &d):mOrigin(o), mDirection(d) {} 
    307310}; 
    308311 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r527 r534  
    607607        if (mUseViewcells) { 
    608608          // construct view cells 
    609           mViewCellsManager->Construct(mObjects, mVssRays); 
     609          if (!mLoadViewCells) 
     610                mViewCellsManager->Construct(mObjects, mVssRays); 
    610611          // evaluate contributions of the intitial rays 
    611612          mViewCellsManager->ComputeSampleContributions(mVssRays); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp

    r516 r534  
    20412041   
    20422042  int nrays = leaf->rays.size(); 
    2043  
    2044  
     2043  int startIndex = rays.size(); 
     2044   
    20452045  AxisAlignedBox3 box = GetBBox(leaf); 
    20462046  AxisAlignedBox3 dirBox = GetDirBBox(leaf); 
    20472047 
    20482048 
    2049   AxisAlignedBox3 sBox(box); 
    2050   AxisAlignedBox3 sDirBox(dirBox); 
    2051   const float smoothRange = 0.5f; 
    2052   sBox.Scale(1.0f + smoothRange); 
    2053   sDirBox.Scale(1.0f + smoothRange); 
    2054   int smoothRays = (int)numberOfRays*0.0f; 
    2055    
    2056 #if AVG_LEN 
    2057   float avgLength = 0.0f; 
    2058  
    2059   if (nrays) { 
    2060         const int numAvg = 5; 
    2061          
    2062         int step = (nrays-1)/10; 
    2063         if (step<1) 
    2064           step = 1; 
    2065          
    2066         int summed = 0; 
    2067         float sumLength = 0.0f; 
    2068         for (int i=0; i < nrays; i+=step) { 
    2069           sumLength += leaf->rays[i].mRay->GetSize(); 
    2070           summed++; 
    2071         } 
    2072    
    2073         avgLength = sumLength/summed; 
    2074   } 
    2075 #endif 
     2049  const float smoothRange = 0.0f; 
     2050  if (smoothRange != 0.0f) { 
     2051        box.Scale(1.0f + smoothRange); 
     2052        dirBox.Scale(1.0f + smoothRange); 
     2053  } 
     2054   
    20762055   
    20772056  Exporter *exporter = NULL; 
     
    21492128                                                  leaf->halton.GetNumber(5), 
    21502129                                                  0.0f); 
     2130                 
    21512131                leaf->halton.GenerateNext(); 
    21522132          } else { 
     
    21602140          } 
    21612141           
    2162           if (i < smoothRays) { 
    2163                 origin = sBox.GetPoint(pVector); 
    2164                 dirVector = sDirBox.GetPoint(dVector); 
    2165           } else { 
    2166                 origin = box.GetPoint(pVector); 
    2167                 dirVector = dirBox.GetPoint(dVector); 
    2168           } 
     2142          origin = box.GetPoint(pVector); 
     2143          dirVector = dirBox.GetPoint(dVector); 
     2144 
    21692145          direction = Vector3(sin(dirVector.x), sin(dirVector.y), cos(dirVector.x)); 
    21702146        } 
     
    22162192  } 
    22172193 
     2194   
    22182195  //  cout<<"desired="<<numberOfRays<<" tries="<<i<<endl; 
    2219    
     2196  // assign probabilitites to the generated rays 
     2197  for (i=startIndex; i < rays.size(); i++) 
     2198        rays[i].mProbability = 1.0f; 
     2199           
    22202200  if (exporter) { 
    22212201        exporter->ExportRays(selectedRays, RgbColor(1, 0, 0)); 
     
    22232203        CLEAR_CONTAINER(selectedRays); 
    22242204  } 
     2205   
     2206   
    22252207} 
    22262208 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r532 r534  
    1515 
    1616bool use2dSampling = false; 
    17 bool useViewspacePlane = true; 
     17bool useViewspacePlane = false; 
    1818 
    1919VssPreprocessor::VssPreprocessor(): 
     
    7878  float bsize = Magnitude(box.Size()); 
    7979 
     80 
     81  if (!mDetectEmptyViewSpace) 
     82        ray.mFlags &= ~Ray::CULL_BACKFACES; 
    8083   
    8184  if (mKdTree->CastRay(ray)) { 
     
    9295  } 
    9396 
    94   bool detectEmptyViewSpace = true; 
    9597         
    96   if (detectEmptyViewSpace) { 
     98  if (mDetectEmptyViewSpace) { 
    9799        SetupRay(ray, pointA, -direction); 
    98100  } else 
    99101        SetupRay(ray, viewPoint, -direction); 
    100          
    101          
     102   
     103  if (!mDetectEmptyViewSpace) 
     104        ray.mFlags &= ~Ray::CULL_BACKFACES; 
     105 
    102106  if (mKdTree->CastRay(ray)) { 
    103107        objectB = ray.intersections[0].mObject; 
     
    111115          return 0; 
    112116  } 
    113  
     117   
    114118  //  if (objectA == NULL && objectB != NULL) { 
    115   if (1) { 
     119  if (mDetectEmptyViewSpace) { 
    116120        // cast again to ensure that there is no objectA 
    117121        SetupRay(ray, pointB, direction); 
     
    121125        } 
    122126  } 
    123    
     127 
    124128   
    125129  VssRay *vssRay  = NULL; 
    126130 
    127131  bool validSample = (objectA != objectB); 
    128   if (0 && detectEmptyViewSpace) {   // consider all samples valid 
     132  if (0 && mDetectEmptyViewSpace) {   // consider all samples valid 
    129133        // check if the viewpoint lies on the line segment AB 
    130134        if (Distance(pointA, pointB) < 
     
    183187  Vector3 point; 
    184188  if (!use2dSampling) { 
    185         Vector3 normal; 
    186         int i = (int)RandomValue(0, (Real)((int)mObjects.size()-1)); 
    187         Intersectable *object = mObjects[i]; 
    188         object->GetRandomSurfacePoint(point, normal); 
     189        if (0) { 
     190          Vector3 normal; 
     191          int i = Random((int)mObjects.size()); 
     192          Intersectable *object = mObjects[i]; 
     193          object->GetRandomSurfacePoint(point, normal); 
     194        } else 
     195          point = mKdTree->GetBox().GetRandomPoint(); 
     196        //        point = viewpoint + UniformRandomVector(); 
     197 
    189198  } else { 
    190199        AxisAlignedBox3 box; 
     
    226235        num = vssTree->GenerateRays(p, rays); 
    227236  } else { 
    228         int leaves = vssTree->stat.Leaves()/2; 
     237        int leaves = vssTree->stat.Leaves(); 
    229238        num = vssTree->GenerateRays(desiredSamples, leaves, rays); 
    230239  } 
     
    243252{ 
    244253  cout<<"Exporting vss rays..."<<endl<<flush; 
    245  
    246   float prob = number/(float)vssRays.size(); 
    247  
    248254 
    249255  Exporter *exporter = NULL; 
     
    261267  } 
    262268 
    263   VssRayContainer rays; for (int i=0; i < vssRays.size(); i++) 
    264         if (RandomValue(0,1) < prob) 
    265           rays.push_back(vssRays[i]); 
    266  
     269  VssRayContainer rays; 
     270  vssRays.SelectRays(number, rays); 
     271   
    267272  exporter->ExportRays(rays, RgbColor(1, 0, 0)); 
    268273 
     
    411416 
    412417  AxisAlignedBox3 *box = new AxisAlignedBox3(mKdTree->GetBox()); 
    413  
     418   
    414419  if (!useViewspacePlane) { 
    415420        float size = 0.05f; 
     
    430435        box->SetMax(1, box->Min(1)); 
    431436 
     437  cout<<"mUseViewSpaceBox="<<mUseViewSpaceBox<<endl; 
    432438  if (mUseViewSpaceBox) 
    433439  { 
     
    440446        mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 
    441447  } 
    442  
     448   
    443449  //-- load view cells from file if requested 
    444450  if (mLoadViewCells) 
     
    464470  else 
    465471  { 
    466           while (totalSamples < mInitialSamples) { 
     472         
     473        while (totalSamples < mInitialSamples) { 
    467474                int passContributingSamples = 0; 
    468475                int passSampleContributions = 0; 
     
    476483                for (int k=0; k < s; k++) { 
    477484                        // changed by matt 
    478                         //Vector3 viewpoint = GetViewpoint(mViewSpaceBox); 
    479485                        Vector3 viewpoint;  
     486                        //                      viewpoint = GetViewpoint(mViewSpaceBox); 
    480487                        mViewCellsManager->GetViewPoint(viewpoint); 
    481488                        Vector3 direction = GetDirection(viewpoint, mViewSpaceBox); 
    482                  
     489 
    483490                        sampleContributions = CastRay(viewpoint, direction, mVssRays); 
    484491 
     
    514521  
    515522          cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
     523 
     524 
     525           
    516526  } 
    517527   
     
    537547  } 
    538548 
    539   //int numExportRays = 10000; 
    540   int numExportRays = 0; 
     549   
     550  int numExportRays = 5000; 
     551  //int numExportRays = 0; 
    541552 
    542553  if (numExportRays) { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssRay.h

    r492 r534  
    6363  // computed by the prperocessor 
    6464  float mWeightedPvsContribution; 
     65 
     66  // probability of this ray 
     67  float mProbability; 
    6568   
    6669  ////////////////////////////// 
     
    8184        mPass(pass), 
    8285        mViewCells(0), 
    83         mWeightedPvsContribution(0) 
    84         //      mT(1.0f) 
     86        mWeightedPvsContribution(0), 
     87        mProbability(1.0f) 
    8588  { 
    8689    Precompute(); 
     
    9396        mOriginObject(ray.sourceObject.mObject), 
    9497        mPass(0), 
    95         mViewCells(0) 
    96         //      mT(1.0f) 
     98        mViewCells(0), 
     99        mProbability(1.0f) 
    97100  { 
    98101        if (ray.sourceObject.mObject) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r529 r534  
    66Scene { 
    77 
    8 #       filename glasgow1.x3d 
     8# filename ../data/glasgow/glasgow1.x3d 
    99#       filename vienna.x3d 
    1010# filename ../data/vienna/vienna-simple.x3d 
     
    1515filename ../data/atlanta/atlanta2.x3d 
    1616# filename ../data/soda/soda.dat 
    17 filename ../data/soda/soda5.dat 
     17# filename ../data/soda/soda5.dat 
    1818} 
    1919 
     
    2323        useGlRenderer true 
    2424#       type sampling 
    25 #       type vss 
    26         type rss 
     25        type vss 
     26#       type rss 
     27        detectEmptyViewSpace false 
    2728} 
    2829 
     
    3031        samplesPerPass  100000 
    3132        initialSamples 500000 
    32         vssSamples 200000 
    33         vssSamplesPerPass 100000 
     33        vssSamples 2000000 
     34        vssSamplesPerPass 200000 
    3435        useImportanceSampling true 
    3536        loadInitialSamples  false 
     
    4445        maxDepth        40 
    4546        minPvs          30 
    46         minRays         1000 
     47        minRays         100 
    4748        minSize         0.001 
    48         maxCostRatio    0.9 
    49         maxRayContribution 0.05 
     49        maxCostRatio    1.5 
     50        maxRayContribution 0.5 
    5051         
    5152        maxTotalMemory  200 
    52         maxStaticMemory 20 
     53        maxStaticMemory 100 
    5354 
    5455        splitType regular 
     
    5758        splitUseOnlyDrivingAxis true 
    5859 
    59         interleaveDirSplits     false 
    60     dirSplitDepth 40 
     60        interleaveDirSplits     true 
     61    dirSplitDepth 0 
    6162 
    6263        numberOfEndPointDomains 10000 
     
    167168 
    168169ViewCells { 
    169         loadFromFile true 
     170        loadFromFile false 
    170171        #type kdTree 
    171172        #type vspKdTree 
    172         type bspTree 
    173         #type vspBspTree 
     173        # type bspTree 
     174        type vspBspTree 
    174175         
    175176        #type sceneDependent 
     
    199200        } 
    200201         
    201         filename ../data/soda5/viewcells_soda5.xml 
     202        filename ../data/soda/viewcells_soda5.xml 
    202203#       filename ../data/atlanta/atlanta_viewcells_large.x3d 
    203204#       filename ../data/vienna/viewcells-25-sel.x3d 
Note: See TracChangeset for help on using the changeset viewer.