Changeset 3234


Ignore:
Timestamp:
12/24/08 15:55:54 (15 years ago)
Author:
mattausch
Message:

visibility solution loader for jiris preprocessor
worked on poisson disc sampling

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
10 added
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp

    r3233 r3234  
    3535        // this sampling scheme has the benefit that it is hierarchical  
    3636        int maxTries = 1000; 
    37         const float f_reduction = 0.9f; 
     37        const float f_reduction = 0.95f; 
    3838         
    3939        float r[2]; 
    4040 
     41        // the maximal possible radius: our radius is a fraction of this radius 
     42        // this is used as a measure of the quality of distribution of the point samples 
     43        const float rmax = 2.0f * mRadius * sqrt(1.0f / (2.0f * sqrt(3.0f) * mNumSamples)); 
     44 
    4145        // generates poisson distribution on disc 
    42         // start with some threshold 
    43         // best case: all samples lie on the circumference of circle 
     46        // start with some thresholds: all samples lie on the circumference of circle 
    4447          
    45         const float eps = 0.2f; 
    46         const float minDist = 2.0f * mRadius * M_PI * (1.0f - eps) / (float)mNumSamples; 
     48        float minDist = 2.0f * rmax; 
    4749        float sqrMinDist = minDist * minDist; 
    4850 
     51        int tries = 0; 
     52 
    4953        //cout << "minDist before= " << minDist << endl; 
    5054        Sample2 *s = (Sample2 *)samples; 
    5155 
    52         int totalTries = 0; 
    53  
    5456        // check if on disc 
    5557        for (int i = 0; i < mNumSamples; ++ i) 
    5658        { 
    57                 int tries = 0; 
    58  
    5959                // repeat until valid sample was found 
    6060                while (1) 
    6161                { 
    62                         ++ tries; 
    63                         ++ totalTries; 
    64  
    65                         // note: should use halton, but seems somewhat broken 
    66                         mHalton->GetNext(r); 
     62                        // q: should we use halton or does it conflict with the poisson disc properties? 
     63                        r[0] = RandomValue(0, 1); r[1] = RandomValue(0, 1); 
     64                        //mHalton->GetNext(r); 
    6765 
    6866                        // scale to -1 .. 1 
     
    9997                        } 
    10098 
     99                        ++ tries; 
     100 
    101101                        if (tries > maxTries) 
    102102                        { 
    103                                 sqrMinDist *= f_reduction; 
    104                                 tries = 0; 
     103                                minDist *= f_reduction; 
     104                                sqrMinDist = minDist * minDist; 
     105 
     106                                maxTries += 1000; 
    105107                        } 
    106108                } 
    107109        } 
    108110 
    109         cout << "minDist after= " << sqrt(sqrMinDist) << " #tries: " << totalTries << endl; 
     111        cout << "minDist after= " << (float)minDist / mNumSamples<< " #tries: " << tries << endl; 
    110112} 
    111113 
Note: See TracChangeset for help on using the changeset viewer.