00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "lux.h"
00025 #include "reflection/bxdf.h"
00026 #include "transport.h"
00027 #include "scene.h"
00028 #include "mc.h"
00029
00030 namespace lux
00031 {
00032
00033
00034 struct BidirVertex;
00035 class BidirIntegrator : public SurfaceIntegrator {
00036 public:
00037
00038 enum LightStrategy { SAMPLE_ALL_UNIFORM, SAMPLE_ONE_UNIFORM,
00039 SAMPLE_AUTOMATIC
00040 };
00041
00042
00043 BidirIntegrator(int ed, int ld, LightStrategy ls) : lightStrategy(ls), maxEyeDepth(ed), maxLightDepth(ld) {}
00044
00045 SWCSpectrum Li(const Scene *scene, const RayDifferential &ray, const Sample *sample, float *alpha) const;
00046 void RequestSamples(Sample *sample, const Scene *scene);
00047 static SurfaceIntegrator *CreateSurfaceIntegrator(const ParamSet ¶ms);
00048 private:
00049
00050 int generatePath(const Scene *scene, const Ray &r, const Sample *sample,
00051 int sampleOffset,
00052 vector<BidirVertex> &vertices) const;
00053 float weightPath(vector<BidirVertex> &eye, int nEye, vector<BidirVertex> &light, int nLight, float pdfLight, bool directLight) const;
00054 SWCSpectrum evalPath(const Scene *scene, vector<BidirVertex> &eye, int nEye,
00055 vector<BidirVertex> &light, int nLight) const;
00056 static float G(const BidirVertex &v0, const BidirVertex &v1);
00057 static bool visible(const Scene *scene, const Point &P0, const Point &P1);
00058
00059 LightStrategy lightStrategy;
00060 int maxEyeDepth, maxLightDepth;
00061 int lightNumOffset, lightPosOffset, lightDirOffset;
00062 int sampleEyeOffset, sampleLightOffset, sampleDirectOffset;
00063 };
00064 struct BidirVertex {
00065 BidirVertex() : bsdf(NULL), eBsdf(NULL), bsdfWeight(0.f), dAWeight(0.f),
00066 rrWeight(1.f), bsdfRWeight(0.f), dARWeight(0.f), rrRWeight(0.f),
00067 ePdf(0.f), ePdfDirect(0.f), flags(BxDFType(0)),
00068 f(0.f), Le(0.f) {}
00069 BSDF *bsdf, *eBsdf;
00070 Point p;
00071 Normal ng, ns;
00072 Vector wi, wo;
00073 float bsdfWeight, dAWeight, rrWeight, bsdfRWeight, dARWeight, rrRWeight, ePdf, ePdfDirect;
00074 BxDFType flags;
00075 SWCSpectrum f, Le;
00076 };
00077
00078 }
00079