00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef LUX_METROPOLIS_H
00026 #define LUX_METROPOLIS_H
00027
00028 #include "sampling.h"
00029 #include "paramset.h"
00030 #include "film.h"
00031
00032 namespace lux
00033 {
00034
00035 class SampleVector {
00036 public:
00037 SampleVector () {}
00038 virtual ~SampleVector() {}
00039 virtual float value (const int i, float defval) const = 0;
00040 };
00041
00042 class MetroSample : public SampleVector {
00043 public:
00044 mutable vector<float> values;
00045 mutable vector<int> modify;
00046 int time;
00047 MetroSample () : time(0) {}
00048 float mutate (const float x) const;
00049 float value (const int i, float defval) const;
00050 MetroSample next () const;
00051 };
00052
00053 class Metropolis : public IntegrationSampler {
00054 public:
00055 Metropolis() { L = 0.f; consec_rejects = 0; }
00056 void SetParams(int mR, float pL) { maxReject = mR; pLarge = pL; }
00057 void SetFilmRes(int fX0, int fX1, int fY0, int fY1) {
00058 xStart = fX0; xEnd = fX1; yStart = fY0; yEnd = fY1; }
00059 bool GetNextSample(Sampler *sampler, Sample *sample, u_int *use_pos);
00060 void GetNext(float& bs1, float& bs2, float& bcs, int pathLength);
00061 void AddSample(const Sample &sample, const Ray &ray,
00062 const Spectrum &L, float alpha, Film *film);
00063
00064 MetroSample msamp, newsamp;
00065 Spectrum L;
00066 int xStart, xEnd, yStart, yEnd, maxReject, consec_rejects;
00067 bool large;
00068 float pLarge;
00069 };
00070
00071 }
00072
00073 #endif // LUX_METROPOLIS_H
00074