00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if defined(_MSC_VER)
00025 #pragma once
00026 #endif
00027
00028 #ifndef PBRT_CORE_SAMPLER_H
00029 #define PBRT_CORE_SAMPLER_H
00030
00031
00032 #include "pbrt.h"
00033 #include "geometry.h"
00034 #include "rng.h"
00035 #include "memory.h"
00036
00037
00038 class Sampler {
00039 public:
00040
00041 virtual ~Sampler();
00042 Sampler(int xstart, int xend, int ystart, int yend,
00043 int spp, float sopen, float sclose);
00044 virtual int GetMoreSamples(Sample *sample, RNG &rng) = 0;
00045 virtual int MaximumSampleCount() = 0;
00046 virtual bool ReportResults(Sample *samples, const RayDifferential *rays,
00047 const Spectrum *Ls, const Intersection *isects, int count);
00048 virtual Sampler *GetSubSampler(int num, int count) = 0;
00049 virtual int RoundSize(int size) const = 0;
00050
00051
00052 const int xPixelStart, xPixelEnd, yPixelStart, yPixelEnd;
00053 const int samplesPerPixel;
00054 const float shutterOpen, shutterClose;
00055 protected:
00056
00057 void ComputeSubWindow(int num, int count, int *xstart, int *xend, int *ystart, int *yend) const;
00058 };
00059
00060
00061 struct CameraSample {
00062 float imageX, imageY;
00063 float lensU, lensV;
00064 float time;
00065 };
00066
00067
00068 struct Sample : public CameraSample {
00069
00070 Sample(Sampler *sampler, SurfaceIntegrator *surf, VolumeIntegrator *vol,
00071 const Scene *scene);
00072 uint32_t Add1D(uint32_t num) {
00073 n1D.push_back(num);
00074 return n1D.size()-1;
00075 }
00076 uint32_t Add2D(uint32_t num) {
00077 n2D.push_back(num);
00078 return n2D.size()-1;
00079 }
00080 ~Sample() {
00081 if (oneD != NULL) {
00082 FreeAligned(oneD[0]);
00083 FreeAligned(oneD);
00084 }
00085 }
00086 Sample *Duplicate(int count) const;
00087
00088
00089 vector<uint32_t> n1D, n2D;
00090 float **oneD, **twoD;
00091 private:
00092
00093 void AllocateSampleMemory();
00094 Sample() { oneD = twoD = NULL; }
00095 };
00096
00097
00098
00099 #endif // PBRT_CORE_SAMPLER_H