source: GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp @ 1952

Revision 1952, 19.3 KB checked in by bittner, 17 years ago (diff)

mutation strategy

Line 
1#include "SamplingStrategy.h"
2#include "Ray.h"
3#include "Intersectable.h"
4#include "Preprocessor.h"
5#include "ViewCellsManager.h"
6#include "AxisAlignedBox3.h"
7#include "RssTree.h"
8
9namespace GtpVisibilityPreprocessor {
10
11
12//HaltonSequence SamplingStrategy::sHalton;
13
14HaltonSequence ObjectBasedDistribution::sHalton;
15HaltonSequence MixtureDistribution::sHalton;
16HaltonSequence GlobalLinesDistribution::sHalton;
17HaltonSequence SpatialBoxBasedDistribution::sHalton;
18HaltonSequence ObjectDirectionBasedDistribution::sHalton;
19HaltonSequence DirectionBasedDistribution::sHalton;
20HaltonSequence MutationBasedDistribution::sHalton;
21
22
23SamplingStrategy::SamplingStrategy(Preprocessor &preprocessor):
24  mPreprocessor(preprocessor), mRatio(1.0f),  mTotalRays(0), mTotalContribution(0.0f)
25{
26 
27}
28
29
30SamplingStrategy::~SamplingStrategy()
31{
32}
33
34int
35SamplingStrategy::GenerateSamples(const int number,
36                                                                  SimpleRayContainer &rays)
37{
38        SimpleRay ray;
39        int samples = 0;
40        int i = 0;
41        const int maxTries = 20;
42        // tmp changed matt. Q: should one rejected sample
43        // terminate the whole method?
44        if (0)
45        {
46                for (; i < number; i++) {
47                        if (!GenerateSample(ray))
48                                return i;
49                        rays.push_back(ray);
50                }
51        }
52        else
53        {
54                for (; i < number; i++)
55                {
56                        int j = 0;
57                        bool sampleGenerated = false;
58
59                        for (j = 0; !sampleGenerated && (j < maxTries); ++ j)
60                        {
61                                sampleGenerated = GenerateSample(ray);
62
63                                if (sampleGenerated)
64                                {               
65                                        ++ samples;
66                                        rays.push_back(ray);
67                                }
68                        }
69                }
70        }
71       
72        return samples;
73}
74
75
76/*********************************************************************/
77/*            Individual sampling strategies implementation          */
78/*********************************************************************/
79
80
81bool ObjectBasedDistribution::GenerateSample(SimpleRay &ray)
82{
83  Vector3 origin, direction;
84 
85  float r[5];
86  sHalton.GetNext(5, r);
87 
88  mPreprocessor.mViewCellsManager->GetViewPoint(origin,
89                                                                                                Vector3(r[2],r[3],r[4]));
90 
91
92  Vector3 point, normal;
93 
94  r[0] *= (float)mPreprocessor.mObjects.size() - 1;
95  const int i = (int)r[0];
96 
97  Intersectable *object = mPreprocessor.mObjects[i];
98 
99  // take the remainder as a parameter over objects surface
100  r[0] -= (float)i;
101 
102  object->GetRandomSurfacePoint(r[0], r[1], point, normal);
103 
104  direction = point - origin;
105 
106  const float c = Magnitude(direction);
107 
108  if (c <= Limits::Small)
109        return false;
110 
111  // $$ jb the pdf is yet not correct for all sampling methods!
112  const float pdf = 1.0f;
113 
114  direction *= 1.0f / c;
115  ray = SimpleRay(origin, direction, OBJECT_BASED_DISTRIBUTION, pdf);
116 
117  return true;
118}
119
120
121bool
122ObjectDirectionBasedDistribution::GenerateSample(SimpleRay &ray)
123{       
124  Vector3 origin, direction;
125
126
127  float r[4];
128  sHalton.GetNext(4, r);
129
130  r[0] *= (float)mPreprocessor.mObjects.size() - 1;
131  const int i = (int)r[0];
132 
133  Intersectable *object = mPreprocessor.mObjects[i];
134 
135  // take the remainder as a parameter over objects surface
136  r[0] -= (float)i;
137
138  Vector3 normal;
139
140  object->GetRandomSurfacePoint(r[0], r[1], origin, normal);
141 
142  direction = Normalize(CosineRandomVector(r[2], r[3], normal));
143 
144  origin += 1e-2f*direction;
145 
146  // $$ jb the pdf is yet not correct for all sampling methods!
147  const float pdf = 1.0f;
148 
149  ray = SimpleRay(origin, direction, OBJECT_DIRECTION_BASED_DISTRIBUTION, pdf);
150 
151  return true;
152}
153
154
155bool DirectionBasedDistribution::GenerateSample(SimpleRay &ray)
156{       
157
158  float r[5];
159  sHalton.GetNext(5, r);
160
161  Vector3 origin, direction;
162  mPreprocessor.mViewCellsManager->GetViewPoint(origin,
163                                                                                                Vector3(r[2],r[3],r[4])
164                                                                                                );
165 
166  direction = UniformRandomVector(r[0], r[1]);
167  const float c = Magnitude(direction);
168 
169  if (c <= Limits::Small)
170        return false;
171 
172  const float pdf = 1.0f;
173 
174  direction *= 1.0f / c;
175  ray = SimpleRay(origin, direction, DIRECTION_BASED_DISTRIBUTION, pdf);
176 
177  return true;
178}
179
180
181bool DirectionBoxBasedDistribution::GenerateSample(SimpleRay &ray)
182{
183        Vector3 origin, direction;
184        mPreprocessor.mViewCellsManager->GetViewPoint(origin);
185
186        const float alpha = RandomValue(0.0f, 2.0f * (float)M_PI);
187        const float beta = RandomValue((float)-M_PI * 0.5f, (float)M_PI * 0.5f);
188       
189        direction = VssRay::GetDirection(alpha, beta);
190       
191        const float c = Magnitude(direction);
192
193        if (c <= Limits::Small)
194                return false;
195
196        const float pdf = 1.0f;
197
198        direction *= 1.0f / c;
199        ray = SimpleRay(origin, direction, DIRECTION_BOX_BASED_DISTRIBUTION, pdf);
200
201        return true;
202}
203
204
205bool SpatialBoxBasedDistribution::GenerateSample(SimpleRay &ray)
206{
207  Vector3 origin, direction;
208
209  float r[6];
210  sHalton.GetNext(6, r);
211  mPreprocessor.mViewCellsManager->GetViewPoint(origin, Vector3(r[0],r[1],r[2]));
212 
213  direction = mPreprocessor.mKdTree->GetBox().GetRandomPoint(Vector3(r[3],
214                                                                                                                                         r[4],
215                                                                                                                                         r[5])
216                                                                                                                                         ) - origin;
217  //cout << "z";
218  const float c = Magnitude(direction);
219 
220  if (c <= Limits::Small)
221        return false;
222 
223  const float pdf = 1.0f;
224 
225  direction *= 1.0f / c;
226  ray = SimpleRay(origin, direction, SPATIAL_BOX_BASED_DISTRIBUTION, pdf);
227 
228  return true;
229}
230
231
232bool ReverseObjectBasedDistribution::GenerateSample(SimpleRay &ray)
233{
234        Vector3 origin, direction;
235
236        mPreprocessor.mViewCellsManager->GetViewPoint(origin);
237
238        Vector3 point;
239        Vector3 normal;
240        //cout << "y";
241        const int i = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f);
242
243        Intersectable *object = mPreprocessor.mObjects[i];
244
245        object->GetRandomSurfacePoint(point, normal);
246       
247        direction = origin - point;
248       
249        // $$ jb the pdf is yet not correct for all sampling methods!
250        const float c = Magnitude(direction);
251       
252        if ((c <= Limits::Small) || (DotProd(direction, normal) < 0))
253        {
254                return false;
255        }
256
257        // $$ jb the pdf is yet not correct for all sampling methods!
258        const float pdf = 1.0f;
259        //cout << "p: " << point << " ";
260        direction *= 1.0f / c;
261        // a little offset
262        point += direction * 0.001f;
263
264        ray = SimpleRay(point, direction, REVERSE_OBJECT_BASED_DISTRIBUTION, pdf);
265       
266        return true;
267}
268
269
270bool ViewCellBorderBasedDistribution::GenerateSample(SimpleRay &ray)
271{
272        Vector3 origin, direction;
273
274        ViewCellContainer &viewCells = mPreprocessor.mViewCellsManager->GetViewCells();
275
276        Vector3 point;
277        Vector3 normal, normal2;
278       
279        const int vcIdx = (int)RandomValue(0, (float)viewCells.size() - 0.5f);
280        const int objIdx = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f);
281
282        Intersectable *object = mPreprocessor.mObjects[objIdx];
283        ViewCell *viewCell = viewCells[vcIdx];
284
285        //cout << "vc: " << vcIdx << endl;
286        //cout << "obj: " << objIdx << endl;
287
288        object->GetRandomSurfacePoint(point, normal);
289        viewCell->GetRandomEdgePoint(origin, normal2);
290
291        direction = point - origin;
292
293        // $$ jb the pdf is yet not correct for all sampling methods!
294        const float c = Magnitude(direction);
295
296        if ((c <= Limits::Small) /*|| (DotProd(direction, normal) < 0)*/)
297        {
298                return false;
299        }
300
301        // $$ jb the pdf is yet not correct for all sampling methods!
302        const float pdf = 1.0f;
303        //cout << "p: " << point << " ";
304        direction *= 1.0f / c;
305        ray = SimpleRay(origin, direction, VIEWCELL_BORDER_BASED_DISTRIBUTION, pdf);
306
307        //cout << "ray: " << ray.mOrigin << " " << ray.mDirection << endl;
308
309        return true;
310}
311
312
313#if 0
314bool ObjectsInteriorDistribution::GenerateSample(SimpleRay &ray)
315{
316        Vector3 origin, direction;
317
318        // get random object
319        const int i = RandomValue(0, mPreprocessor.mObjects.size() - 1);
320
321        const Intersectable *obj = mPreprocessor.mObjects[i];
322
323        // note: if we load the polygons as meshes,
324        // asymtotically every second sample is lost!
325        origin = obj->GetBox().GetRandomPoint();
326
327        // uniformly distributed direction
328        direction = UniformRandomVector();
329
330        const float c = Magnitude(direction);
331
332        if (c <= Limits::Small)
333                return false;
334
335        const float pdf = 1.0f;
336
337        direction *= 1.0f / c;
338        ray = SimpleRay(origin, direction, pdf);
339
340        return true;
341}
342
343#endif
344
345
346bool ReverseViewSpaceBorderBasedDistribution::GenerateSample(SimpleRay &ray)
347{
348        Vector3 origin, direction;
349
350        origin = mPreprocessor.mViewCellsManager->GetViewSpaceBox().GetRandomSurfacePoint();
351
352        Vector3 point;
353        Vector3 normal;
354        //cout << "y";
355        const int i = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f);
356
357        Intersectable *object = mPreprocessor.mObjects[i];
358
359        object->GetRandomSurfacePoint(point, normal);
360       
361        direction = origin - point;
362       
363        // $$ jb the pdf is yet not correct for all sampling methods!
364        const float c = Magnitude(direction);
365       
366        if ((c <= Limits::Small) || (DotProd(direction, normal) < 0))
367        {
368                return false;
369        }
370
371        // $$ jb the pdf is yet not correct for all sampling methods!
372        const float pdf = 1.0f;
373        //cout << "p: " << point << " ";
374        direction *= 1.0f / c;
375        // a little offset
376        point += direction * 0.001f;
377
378        ray = SimpleRay(point, direction, REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION, pdf);
379       
380        return true;
381}
382
383
384bool ViewSpaceBorderBasedDistribution::GenerateSample(SimpleRay &ray)
385{
386        Vector3 origin, direction;
387
388        origin = mPreprocessor.mViewCellsManager->GetViewSpaceBox().GetRandomSurfacePoint();
389
390        Vector3 point;
391        Vector3 normal;
392        //cout << "w";
393        const int i = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f);
394
395        Intersectable *object = mPreprocessor.mObjects[i];
396
397        object->GetRandomSurfacePoint(point, normal);
398        direction = point - origin;
399
400        // $$ jb the pdf is yet not correct for all sampling methods!
401        const float c = Magnitude(direction);
402
403        if (c <= Limits::Small)
404                return false;
405
406        // $$ jb the pdf is yet not correct for all sampling methods!
407        const float pdf = 1.0f;
408       
409        direction *= 1.0f / c;
410
411        // a little offset
412        origin += direction * 0.001f;
413
414        ray = SimpleRay(origin, direction, VIEWSPACE_BORDER_BASED_DISTRIBUTION, pdf);
415
416        return true;
417}
418
419
420
421
422bool
423GlobalLinesDistribution::GenerateSample(SimpleRay &ray)
424{
425  Vector3 origin, termination, direction;
426
427  float radius = 0.5f*Magnitude(mPreprocessor.mViewCellsManager->GetViewSpaceBox().Size());
428  Vector3 center = mPreprocessor.mViewCellsManager->GetViewSpaceBox().Center();
429
430  const int tries = 1000;
431  int i;
432  for (i=0; i < tries; i++) {
433        float r[4];
434        sHalton.GetNext(4, r);
435       
436        origin = center + (radius*UniformRandomVector(r[0], r[1]));
437        termination = center + (radius*UniformRandomVector(r[2], r[3]));
438       
439        direction = termination - origin;
440       
441       
442        // $$ jb the pdf is yet not correct for all sampling methods!
443        const float c = Magnitude(direction);
444        if (c <= Limits::Small)
445          return false;
446       
447        direction *= 1.0f / c;
448
449        // check if the ray intersects the view space box
450        static Ray ray;
451        ray.Init(origin, direction, Ray::LOCAL_RAY);   
452       
453        float tmin, tmax;
454        if (mPreprocessor.mViewCellsManager->
455                GetViewSpaceBox().ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax))
456          break;
457  }
458 
459  if (i!=tries) {
460        // $$ jb the pdf is yet not correct for all sampling methods!
461        const float pdf = 1.0f;
462       
463       
464        ray = SimpleRay(origin, direction, GLOBAL_LINES_DISTRIBUTION, pdf);
465        ray.mType = Ray::GLOBAL_RAY;
466        return true;
467  }
468 
469  return false;
470}
471
472
473  // has to called before first usage
474void
475MixtureDistribution::Init()
476{
477  for (int i=0; i < mDistributions.size(); i++) {
478        // small non-zero value
479        mDistributions[i]->mRays = 1;
480        // unit contribution per ray
481        if (1 || mDistributions[i]->mType != RSS_BASED_DISTRIBUTION)
482          mDistributions[i]->mContribution = 1.0f;
483        else
484          mDistributions[i]->mContribution = 0.0f;
485  }
486  UpdateRatios();
487}
488
489void
490MixtureDistribution::Reset()
491{
492  for (int i=0; i < mDistributions.size(); i++) {
493        // small non-zero value
494        mDistributions[i]->mTotalRays = 0;
495        // unit contribution per ray
496        mDistributions[i]->mTotalContribution = 0.0f;
497  }
498  UpdateRatios();
499}
500
501// Generate a new sample according to a mixture distribution
502bool
503MixtureDistribution::GenerateSample(SimpleRay &ray)
504{
505  float r;
506  sHalton.GetNext(1, &r);
507  int i;
508  // pickup a distribution
509  for (i=0; i < mDistributions.size()-1; i++)
510        if (r < mDistributions[i]->mRatio)
511          break;
512
513  return mDistributions[i]->GenerateSample(ray);
514}
515
516  // add contributions of the sample to the strategies
517void
518MixtureDistribution::ComputeContributions(VssRayContainer &vssRays)
519{
520  int i;
521 
522  VssRayContainer::iterator it = vssRays.begin();
523
524  for (i=0; i < mDistributions.size(); i++) {
525        mDistributions[i]->mContribution = 0;
526        mDistributions[i]->mRays = 0;
527  }
528
529  for(; it != vssRays.end(); ++it) {
530        VssRay *ray = *it;
531        for (i=0; i < mDistributions.size()-1; i++) {
532          if (mDistributions[i]->mType == ray->mDistribution)
533                break;
534        }
535 
536        float contribution =
537          mPreprocessor.mViewCellsManager->ComputeSampleContribution(*ray,
538                                                                                                                                 true,
539                                                                                                                                 false);
540
541        mDistributions[i]->mContribution += contribution;
542        mDistributions[i]->mRays ++;
543       
544        mDistributions[i]->mTotalContribution += contribution;
545        mDistributions[i]->mTotalRays ++;
546  }
547
548 
549  UpdateRatios();
550}
551
552void
553MixtureDistribution::UpdateDistributions(VssRayContainer &vssRays)
554{
555  // now update the distributions with all the rays
556  for (int i=0; i < mDistributions.size(); i++) {
557        mDistributions[i]->Update(vssRays);
558  }
559}
560 
561void
562MixtureDistribution::UpdateRatios()
563{
564  // now compute importance (ratio) of all distributions
565  float sum = 0.0f;
566  int i;
567  for (i=0; i < mDistributions.size(); i++) {
568        cout<<i<<": c="<<mDistributions[i]->mContribution<<
569          " rays="<<mDistributions[i]->mRays<<endl;
570        float importance = 0.0f;
571        if (mDistributions[i]->mRays != 0) {
572          //      importance = pow(mDistributions[i]->mContribution/mDistributions[i]->mRays, 3);
573          importance = mDistributions[i]->mContribution/mDistributions[i]->mRays;
574        }
575        mDistributions[i]->mRatio = importance;
576        sum += importance;
577  }
578
579  const float minratio = 0.02f;
580  float threshold = minratio*sum;
581  for (i=0; i < mDistributions.size(); i++) {
582        if (mDistributions[i]->mRatio < threshold) {
583          sum += threshold - mDistributions[i]->mRatio;
584          mDistributions[i]->mRatio = threshold;
585        }
586  }
587 
588  mDistributions[0]->mRatio /= sum;
589       
590  for (i=1; i < mDistributions.size(); i++) {
591        float r = mDistributions[i]->mRatio / sum;
592        mDistributions[i]->mRatio = mDistributions[i-1]->mRatio + r;
593  }
594 
595  cout<<"ratios: ";
596  float last = 0.0f;
597  for (i=0; i < mDistributions.size(); i++) {
598        cout<<mDistributions[i]->mRatio-last<<" ";
599        last = mDistributions[i]->mRatio;
600  }
601  cout<<endl;
602}
603
604
605
606bool
607MixtureDistribution::Construct(char *str)
608{
609  char *curr = str;
610
611  while (1) {
612        char *e = strchr(curr,'+');
613        if (e!=NULL) {
614          *e=0;
615        }
616       
617        if (strcmp(curr, "rss")==0) {
618          mDistributions.push_back(new RssBasedDistribution(mPreprocessor));
619        } else
620          if (strcmp(curr, "object")==0) {
621                mDistributions.push_back(new ObjectBasedDistribution(mPreprocessor));
622          } else
623                if (strcmp(curr, "spatial")==0) {
624                  mDistributions.push_back(new SpatialBoxBasedDistribution(mPreprocessor));
625                } else
626                  if (strcmp(curr, "global")==0) {
627                        mDistributions.push_back(new GlobalLinesDistribution(mPreprocessor));
628                  } else
629                        if (strcmp(curr, "direction")==0) {
630                          mDistributions.push_back(new DirectionBasedDistribution(mPreprocessor));
631                        } else
632                          if (strcmp(curr, "object_direction")==0) {
633                                mDistributions.push_back(new ObjectDirectionBasedDistribution(mPreprocessor));
634                          } else
635                                if (strcmp(curr, "reverse_object")==0) {
636                                  mDistributions.push_back(new ReverseObjectBasedDistribution(mPreprocessor));
637                                } else
638                                  if (strcmp(curr, "reverse_viewspace_border")==0) {
639                                        mDistributions.push_back(new ReverseViewSpaceBorderBasedDistribution(mPreprocessor));
640                                  } else
641                                        if (strcmp(curr, "mutation")==0) {
642                                          mDistributions.push_back(new MutationBasedDistribution(mPreprocessor));
643                                        }
644       
645       
646        if (e==NULL)
647          break;
648        curr = e+1;
649  }
650
651  Init();
652  return true;
653}
654
655
656
657void
658MutationBasedDistribution::Update(VssRayContainer &vssRays)
659{
660  //  for (int i=0; i < mRays.size(); i++)
661  //    cout<<mRays[i].mSamples<<" ";
662  //  cout<<endl;
663 
664  for (int i=0; i < vssRays.size(); i++) {
665        VssRay *newRay = vssRays[i];
666        if (newRay->mPvsContribution) {
667          // add this ray
668          newRay->Ref();
669          if (mRays.size() < mMaxRays)
670                mRays.push_back(RayEntry(newRay));
671          else {
672                // unref the old ray
673                VssRay *oldRay = mRays[mBufferStart].mRay;
674                oldRay->Unref();
675                if (oldRay->RefCount() == 0)
676                  delete oldRay;
677                mRays[mBufferStart] = RayEntry(newRay);
678                mBufferStart++;
679                if (mBufferStart >= mMaxRays)
680                  mBufferStart = 0;
681          }
682        }
683  }
684}
685
686bool
687MutationBasedDistribution::GenerateSample(SimpleRay &sray)
688{
689  float r[5];
690  sHalton.GetNext(5, r);
691
692  if (mRays.size() == 0) {
693        // use direction based distribution
694        Vector3 origin, direction;
695        mPreprocessor.mViewCellsManager->GetViewPoint(origin,
696                                                                                                  Vector3(r[0], r[1], r[2]));
697       
698        direction = UniformRandomVector(r[3], r[4]);
699       
700        const float pdf = 1.0f;
701        sray = SimpleRay(origin, direction, MUTATION_BASED_DISTRIBUTION, pdf);
702
703        return true;
704  }
705 
706  //  int index = (int) (r[0]*mRays.size());
707  //  if (index >= mRays.size()) {
708  //    cerr<<"mutation: index out of bounds\n";
709  //    exit(1);
710  //  }
711
712  // get tail of the buffer
713  int index = (mLastIndex+1)%mRays.size();
714  if (mRays[index].mSamples > mRays[mLastIndex].mSamples) {
715        // search back for index where this is valid
716        index = (mLastIndex - 1 + mRays.size())%mRays.size();
717        for (int i=0; i < mRays.size(); i++) {
718          if (mRays[index].mSamples > mRays[mLastIndex].mSamples)
719                break;
720          index = (index - 1 + mRays.size())%mRays.size();
721        }
722        // go one step back
723        index = (index+1)%mRays.size();
724  }
725 
726  VssRay *ray = mRays[index].mRay;
727  mRays[index].mSamples++;
728  mLastIndex = index;
729 
730  Vector3 v;
731  // mutate the origin
732  Vector3 d = ray->GetDir();
733  if (d.DrivingAxis() == 0)
734        v = Vector3(0, r[1]-0.5f, r[2]-0.5f);
735  else
736        if (d.DrivingAxis() == 1)
737          v = Vector3(r[1]-0.5f, 0, r[2]-0.5f);
738        else
739          v = Vector3(r[1]-0.5f, r[2]-0.5f, 0);
740
741  v=v*mOriginMutationSize;
742
743  Vector3 origin = ray->mOrigin + v;
744 
745  // mutate the termination
746  if (d.DrivingAxis() == 0)
747        v = Vector3(0, r[3]-0.5f, r[4]-0.5f);
748  else
749        if (d.DrivingAxis() == 1)
750          v = Vector3(r[3]-0.5f, 0, r[4]-0.5f);
751        else
752          v = Vector3(r[3]-0.5f, r[4]-0.5f, 0);
753
754  float size = 1.5f*Magnitude(ray->mTerminationObject->GetBox().Diagonal());
755  if (size < Limits::Small)
756        return false;
757 
758//   Vector3 nv;
759 
760//   if (Magnitude(v) > Limits::Small)
761//      nv = Normalize(v);
762//   else
763//      nv = v;
764 
765//  v = nv*size + v*size;
766
767  v = v*size;
768
769  Vector3 termination = ray->mTermination + v;
770 
771  Vector3 direction = termination - origin;
772
773  if (Magnitude(direction) < Limits::Small)
774        return false;
775
776  // shift the origin a little bit
777  origin += direction*0.05f;
778
779  direction.Normalize();
780 
781  // $$ jb the pdf is yet not correct for all sampling methods!
782  const float pdf = 1.0f;
783 
784  sray = SimpleRay(origin, direction, MUTATION_BASED_DISTRIBUTION, pdf);
785  return true;
786}
787
788MutationBasedDistribution::MutationBasedDistribution(Preprocessor &preprocessor) :
789  SamplingStrategy(preprocessor)
790{
791  mType = MUTATION_BASED_DISTRIBUTION;
792  mBufferStart = 0;
793  mMaxRays = 1000000;
794
795  mOriginMutationSize = 2.0f;
796  mLastIndex = 0;
797  //  mOriginMutationSize = Magnitude(preprocessor.mViewCellsManager->
798  //                                                              GetViewSpaceBox().Diagonal())*1e-3;
799 
800}
801
802}
803
804
Note: See TracBrowser for help on using the repository browser.