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 "light.h"
00026 #include "shape.h"
00027 #include "scene.h"
00028 #include "mipmap.h"
00029
00030 namespace lux
00031 {
00032
00033
00034 class GonioPhotometricLight : public Light {
00035 public:
00036
00037 GonioPhotometricLight(const Transform &light2world, const Spectrum &, const
00038 string &texname);
00039 SWCSpectrum Sample_L(const Point &p, Vector *wi, VisibilityTester *vis) const;
00040 ~GonioPhotometricLight() { delete mipmap; }
00041 bool IsDeltaLight() const { return true; }
00042 Spectrum Scale(const Vector &w) const {
00043 Vector wp = Normalize(WorldToLight(w));
00044 swap(wp.y, wp.z);
00045 float theta = SphericalTheta(wp);
00046 float phi = SphericalPhi(wp);
00047 float s = phi * INV_TWOPI, t = theta * INV_PI;
00048 return mipmap ? mipmap->Lookup(s, t) : 1.f;
00049 }
00050 SWCSpectrum Power(const Scene *) const {
00051 return 4.f * M_PI * Intensity *
00052 mipmap->Lookup(.5f, .5f, .5f);
00053 }
00054 SWCSpectrum Sample_L(const Point &P, float u1, float u2, float u3,
00055 Vector *wo, float *pdf, VisibilityTester *visibility) const;
00056 SWCSpectrum Sample_L(const Scene *scene, float u1, float u2,
00057 float u3, float u4, Ray *ray, float *pdf) const;
00058 float Pdf(const Point &, const Vector &) const;
00059
00060 static Light *CreateLight(const Transform &light2world,
00061 const ParamSet ¶mSet);
00062 private:
00063
00064 Point lightPos;
00065 Spectrum Intensity;
00066 MIPMap<Spectrum> *mipmap;
00067
00068 };
00069
00070 }
00071