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 "mipmap.h"
00028
00029 namespace lux
00030 {
00031
00032
00033 class ProjectionLight : public Light {
00034 public:
00035
00036 ProjectionLight(const Transform &light2world, const Spectrum &intensity,
00037 const string &texname, float fov);
00038 ~ProjectionLight();
00039 SWCSpectrum Sample_L(const Point &p, Vector *wi, VisibilityTester *vis) const;
00040 bool IsDeltaLight() const { return true; }
00041 Spectrum Projection(const Vector &w) const;
00042 SWCSpectrum Power(const Scene *) const {
00043 return Intensity * 2.f * M_PI * (1.f - cosTotalWidth) *
00044 projectionMap->Lookup(.5f, .5f, .5f);
00045 }
00046 SWCSpectrum Sample_L(const Point &P, float u1, float u2, float u3,
00047 Vector *wo, float *pdf, VisibilityTester *visibility) const;
00048 SWCSpectrum Sample_L(const Scene *scene, float u1, float u2,
00049 float u3, float u4, Ray *ray, float *pdf) const;
00050 float Pdf(const Point &, const Vector &) const;
00051
00052 static Light *CreateLight(const Transform &light2world,
00053 const ParamSet ¶mSet);
00054 private:
00055
00056 MIPMap<Spectrum> *projectionMap;
00057 Point lightPos;
00058 Spectrum Intensity;
00059 Transform lightProjection;
00060 float hither, yon;
00061 float screenX0, screenX1, screenY0, screenY1;
00062 float cosTotalWidth;
00063 };
00064
00065 }