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_SAMPLERS_BESTCANDIDATE_H
00029 #define PBRT_SAMPLERS_BESTCANDIDATE_H
00030
00031
00032 #include "sampler.h"
00033 #include "paramset.h"
00034 #include "film.h"
00035
00036
00037 #define SQRT_SAMPLE_TABLE_SIZE 64
00038 #define SAMPLE_TABLE_SIZE (SQRT_SAMPLE_TABLE_SIZE * \
00039 SQRT_SAMPLE_TABLE_SIZE)
00040
00041
00042 class BestCandidateSampler : public Sampler {
00043 public:
00044
00045 BestCandidateSampler(int xstart, int xend, int ystart, int yend,
00046 int nPixelSamples, float sopen, float sclose)
00047 : Sampler(xstart, xend, ystart, yend, nPixelSamples, sopen, sclose) {
00048 tableWidth = (float)SQRT_SAMPLE_TABLE_SIZE /
00049 (float)sqrtf(nPixelSamples);
00050 xTileStart = Floor2Int(xstart / tableWidth);
00051 xTileEnd = Floor2Int(xend / tableWidth);
00052 yTileStart = Floor2Int(ystart / tableWidth);
00053 yTileEnd = Floor2Int(yend / tableWidth);
00054 xTile = xTileStart;
00055 yTile = yTileStart;
00056 tableOffset = 0;
00057
00058 RNG tileRng(xTile + (yTile<<8));
00059 for (int i = 0; i < 3; ++i)
00060 sampleOffsets[i] = tileRng.RandomFloat();
00061 }
00062 Sampler *GetSubSampler(int num, int count);
00063 int RoundSize(int size) const {
00064 return RoundUpPow2(size);
00065 }
00066 int MaximumSampleCount() { return 1; }
00067 int GetMoreSamples(Sample *sample, RNG &rng);
00068 private:
00069
00070 float tableWidth;
00071 int tableOffset;
00072 int xTileStart, xTileEnd, yTileStart, yTileEnd;
00073 int xTile, yTile;
00074 static const float sampleTable[SAMPLE_TABLE_SIZE][5];
00075 float sampleOffsets[3];
00076 };
00077
00078
00079 BestCandidateSampler *CreateBestCandidateSampler(const ParamSet ¶ms, const Film *film,
00080 const Camera *camera);
00081
00082 #endif // PBRT_SAMPLERS_BESTCANDIDATE_H