Ignore:
Timestamp:
12/15/06 23:40:27 (18 years ago)
Author:
bittner
Message:

experiments with different contribution computations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1895 r1900  
    2727 
    2828// $$JB HACK 
    29 #define USE_KD_PVS 0 
     29#define USE_KD_PVS 1 
    3030 
    3131#define KD_PVS_AREA (1e-5f) 
     32 
     33#define USE_RAY_LENGTH_AS_CONTRIBUTION 0 
     34#define DIST_WEIGHTED_CONTRIBUTION 1 
    3235 
    3336namespace GtpVisibilityPreprocessor { 
     
    15361539                                                                                         const bool storeViewCells) 
    15371540{ 
    1538   // view cells not yet constructed 
    1539   if (!ViewCellsConstructed()) 
    1540         return 0.0f; 
    1541    
    15421541  float sum = 0.0f; 
     1542 
    15431543  VssRayContainer::const_iterator it, it_end = rays.end(); 
    15441544   
    15451545  for (it = rays.begin(); it != it_end; ++ it)  
    15461546        { 
    1547           sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 
     1547          if (!ViewCellsConstructed()) { 
     1548                // view cells not yet constructed 
     1549                // just take the lenghts of the rays as contributions 
     1550                if ((*it)->mTerminationObject) 
     1551                  sum += (*it)->Length(); 
     1552          } else { 
     1553                sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 
     1554          } 
    15481555        } 
    15491556   
     
    20092016float 
    20102017ViewCellsManager::ComputeSampleContribution(VssRay &ray, 
    2011                                                                                                   const bool addRays, 
    2012                                                                                                   const bool storeViewCells) 
     2018                                                                                        const bool addRays, 
     2019                                                                                        const bool storeViewCells) 
    20132020{ 
    20142021  ray.mPvsContribution = 0; 
     
    20592066                        { 
    20602067                          // todo: maybe not correct for kd node pvs 
    2061                           if (viewcell->GetPvs().GetSampleContribution( 
    2062                                                                                                                    terminationObj, ray.mPdf, contribution)) 
     2068                          bool absContribution = viewcell->GetPvs().GetSampleContribution( 
     2069                                                                                                                                                          terminationObj, 
     2070                                                                                                                                                          ray.mPdf, 
     2071                                                                                                                                                          contribution); 
     2072#if DIST_WEIGHTED_CONTRIBUTION 
     2073                          // clear the relative contribution 
     2074                          contribution = 0.0f; 
     2075#endif 
     2076                          if (absContribution) 
    20632077                                { 
    20642078                                  ++ ray.mPvsContribution; 
     
    20732087#endif 
    20742088                                  } 
     2089#if DIST_WEIGHTED_CONTRIBUTION  
     2090                                  // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the 
     2091                                  // object-> a new contribution in the proximity of the viewcell has a larger weight! 
     2092                                  contribution = 1.0f/SqrDistance(GetViewCellBox(viewcell).Center(), 
     2093                                                                                                  ray.mTermination); 
     2094#endif 
    20752095                                } 
    20762096                           
     
    20792099                } 
    20802100        } 
    2081    
     2101 
     2102#if USE_RAY_LENGTH_AS_CONTRIBUTION 
     2103  float c = 0.0f; 
     2104  if (terminationObj)  
     2105        c = ray.Length(); 
     2106  ray.mRelativePvsContribution = ray.mPvsContribution = c; 
     2107  return c; 
     2108#else 
    20822109  return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 
    20832110        (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 
     2111#endif 
    20842112} 
    20852113 
Note: See TracChangeset for help on using the changeset viewer.