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_LIGHTS_GONIOMETRIC_H
00029 #define PBRT_LIGHTS_GONIOMETRIC_H
00030
00031
00032 #include "pbrt.h"
00033 #include "light.h"
00034 #include "shape.h"
00035 #include "scene.h"
00036 #include "mipmap.h"
00037
00038
00039 class GonioPhotometricLight : public Light {
00040 public:
00041
00042 GonioPhotometricLight(const Transform &light2world, const Spectrum &, const
00043 string &texname);
00044 Spectrum Sample_L(const Point &p, float pEpsilon, const LightSample &ls,
00045 float time, Vector *wi, float *pdf, VisibilityTester *vis) const;
00046 ~GonioPhotometricLight() { delete mipmap; }
00047 bool IsDeltaLight() const { return true; }
00048 Spectrum Scale(const Vector &w) const {
00049 Vector wp = Normalize(WorldToLight(w));
00050 swap(wp.y, wp.z);
00051 float theta = SphericalTheta(wp);
00052 float phi = SphericalPhi(wp);
00053 float s = phi * INV_TWOPI, t = theta * INV_PI;
00054 return (mipmap == NULL) ? 1.f :
00055 Spectrum(mipmap->Lookup(s, t, SPECTRUM_ILLUMINANT));
00056 }
00057 Spectrum Power(const Scene *) const;
00058 Spectrum Sample_L(const Scene *scene, const LightSample &ls, float u1, float u2,
00059 float time, Ray *ray, Normal *Ns, float *pdf) const;
00060 float Pdf(const Point &, const Vector &) const;
00061 private:
00062
00063 Point lightPos;
00064 Spectrum Intensity;
00065 MIPMap<RGBSpectrum> *mipmap;
00066 };
00067
00068
00069 GonioPhotometricLight *CreateGoniometricLight(const Transform &light2world,
00070 const ParamSet ¶mSet);
00071
00072 #endif // PBRT_LIGHTS_GONIOMETRIC_H