Ignore:
Timestamp:
11/10/05 09:55:50 (19 years ago)
Author:
bittner
Message:

vsspreprocessor updates

File:
1 edited

Legend:

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

    r387 r401  
    3939VssPreprocessor::CastRay( 
    4040                                                                                                 Vector3 &viewPoint, 
    41                                                                                                  Vector3 &direction 
     41                                                                                                 Vector3 &direction, 
     42                                                                                                 VssRayContainer &vssRays 
    4243                                                                                                 ) 
    4344{ 
     
    6061                box.ComputeMinMaxT(ray, &tmin, &tmax); 
    6162                if (tmax > bsize) { 
    62                         cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 
    63                         cerr<<"ray"<<ray<<endl; 
     63                        //                      cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 
     64                        //                      cerr<<"ray"<<ray<<endl; 
    6465                } 
    6566                pointA = ray.Extrap(tmax); 
     
    8586                box.ComputeMinMaxT(ray, &tmin, &tmax); 
    8687                if (tmax > bsize) { 
    87                         cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 
    88                         cerr<<"ray"<<ray<<endl; 
     88                        //                      cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 
     89                        //                      cerr<<"ray"<<ray<<endl; 
    8990                } 
    9091                 
     
    108109                                                                                                        objectB, 
    109110                                                                                                        objectA); 
    110                         mVssRays.push_back(vssRay); 
     111                        vssRays.push_back(vssRay); 
    111112                        hits ++; 
    112113                } 
     
    117118                                                                                                        objectA, 
    118119                                                                                                        objectB); 
    119                         mVssRays.push_back(vssRay); 
     120                        vssRays.push_back(vssRay); 
    120121                        hits ++; 
    121122                } 
     
    150151} 
    151152 
     153int 
     154VssPreprocessor::RandomizedImportanceSampling(VssTree *vssTree, 
     155                                                                                                                                                                                        const int desiredSamples) 
     156{ 
     157        float minRayContribution; 
     158        float maxRayContribution; 
     159        float avgRayContribution; 
     160 
     161        vssTree->GetRayContributionStatistics(minRayContribution, 
     162                                                                                                                                                                maxRayContribution, 
     163                                                                                                                                                                avgRayContribution); 
     164 
     165        cout<< 
     166                "#MIN_RAY_CONTRIB\n"<<minRayContribution<<endl<< 
     167                "#MAX_RAY_CONTRIB\n"<<maxRayContribution<<endl<< 
     168                "#AVG_RAY_CONTRIB\n"<<avgRayContribution<<endl; 
     169         
     170        float p = desiredSamples/(float)(avgRayContribution*vssTree->stat.Leaves()); 
     171        SimpleRayContainer rays; 
     172        int num = vssTree->GenerateRays(p, rays); 
     173        cout<<"Generated "<<num<<" rays."<<endl; 
     174         
     175        VssRayContainer  vssRays; 
     176         
     177        for (int i=0; i < rays.size(); i++) 
     178                CastRay(rays[i].mOrigin, rays[i].mDirection, vssRays); 
     179 
     180        vssTree->AddRays(vssRays); 
     181        return num; 
     182} 
    152183 
    153184 
     
    175206        } 
    176207         
    177         bool useViewSpaceBox = true; 
     208        bool useViewSpaceBox = false; 
    178209        if (useViewSpaceBox) 
    179210                viewSpaceBox = &box; 
    180          
     211 
     212        VssTree *vssTree = NULL; 
     213 
    181214  while (totalSamples < mTotalSamples) { 
    182215                int passContributingSamples = 0; 
     
    193226                        Vector3 direction = GetDirection(viewpoint); 
    194227                         
    195                         sampleContributions = CastRay(viewpoint, direction); 
     228                        sampleContributions = CastRay(viewpoint, direction, mVssRays); 
    196229                         
    197230                         
     
    226259                        "#AvgPVS\n"<< pvsSize/(float)mObjects.size() << endl << 
    227260                        "#AvgRayContrib\n" << avgRayContrib << endl; 
     261 
     262 
     263 
     264                 
    228265        } 
    229266         
     
    257294        cout<<"done."<<endl<<flush; 
    258295 
    259         VssTree *vssTree = new VssTree; 
    260  
     296 
     297 
     298 
     299        vssTree = new VssTree; 
     300         
    261301        vssTree->Construct(mVssRays, viewSpaceBox); 
    262302 
    263303        cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 
    264          
    265  
    266  
     304 
     305         
     306        int samples = 0; 
     307        for (int i=0; i < 50; i++) { 
     308                int num = 100000; 
     309                if (0) { 
     310                        VssRayContainer vssRays; 
     311                        for (int j=0; j < num; j++) { 
     312                                Vector3 viewpoint = GetViewpoint(viewSpaceBox); 
     313                                Vector3 direction = GetDirection(viewpoint); 
     314                                CastRay(viewpoint, direction, vssRays); 
     315                        } 
     316                        vssTree->AddRays(vssRays); 
     317                } else { 
     318                        num = RandomizedImportanceSampling(vssTree, num); 
     319                } 
     320                samples+=num; 
     321                float pvs = vssTree->GetAvgPvsSize(); 
     322                cout<<samples<<" avgPVS ="<<pvs<<endl; 
     323        } 
     324 
     325        delete vssTree; 
     326         
    267327  return true; 
    268328} 
Note: See TracChangeset for help on using the changeset viewer.