Ignore:
Timestamp:
06/04/08 01:49:14 (16 years ago)
Author:
mattausch
Message:

added new importance sampling method for gvs

File:
1 edited

Legend:

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

    r2728 r2735  
    1  
    21#include "SamplingStrategy.h" 
    32#include "Ray.h" 
     
    1817#define USE_HALTON 1 
    1918 
     19 
    2020namespace GtpVisibilityPreprocessor { 
    2121 
     
    2727#endif 
    2828   
    29 //HaltonSequence SamplingStrategy::sHalton; 
    30  
    3129HaltonSequence ObjectBasedDistribution::sHalton; 
    3230HaltonSequence MixtureDistribution::sHalton; 
     
    3937HaltonSequence ViewCellBasedDistribution::sHalton; 
    4038HaltonSequence ViewCellBorderBasedDistribution::sHalton; 
     39HaltonSequence ProbablyVisibleDistribution::sHalton; 
     40 
     41 
    4142 
    4243SamplingStrategy::SamplingStrategy(Preprocessor &preprocessor):  
     
    575576  { 
    576577#ifdef USE_PERFTIMER 
    577         const float vcTime = viewCellCastTimer.TotalTime(); 
    578         const float pvsTime = pvsTimer.TotalTime(); 
    579         const float haltonTime = haltonTimer.TotalTime(); 
     578        const double vcTime = viewCellCastTimer.TotalTime(); 
     579        const double pvsTime = pvsTimer.TotalTime(); 
     580        const double haltonTime = haltonTimer.TotalTime(); 
    580581         
    581582        cout << "view cell cast time: " << vcTime << " s" << endl; 
     
    881882 
    882883 
    883 } 
    884  
    885  
     884bool ProbablyVisibleDistribution::GenerateSample(SimpleRay &ray) 
     885{        
     886        static Vector3 origin; 
     887        static Vector3 direction;  
     888        static Vector3 point; 
     889        static Vector3 normal; 
     890         
     891        float r[2]; 
     892        sHalton.GetNext(2, r); 
     893  
     894        r[0] *= (float)(*mObjects).size() - 1.0f; 
     895        const int i = (int)r[0]; 
     896  
     897        Intersectable *obj = (*mObjects)[i]; 
     898         
     899        obj->GetRandomSurfacePoint(point, normal); 
     900 
     901        // get point on view cell surface 
     902        if (1) 
     903                origin = mViewCell->GetBox().GetRandomSurfacePoint(); 
     904        else 
     905                origin = mViewCell->GetBox().GetUniformRandomSurfacePoint(); 
     906 
     907        direction = point - origin; 
     908   
     909        const float c = Magnitude(direction); 
     910   
     911        if (c <= Limits::Small)  
     912                return false; 
     913 
     914        ray = SimpleRay(origin, direction, PROBABLY_VISIBLE_DISTRIBUTION, 1.0f); 
     915 
     916        return true; 
     917} 
     918 
     919} 
     920 
     921 
Note: See TracChangeset for help on using the changeset viewer.