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,
00037 const boost::shared_ptr< Texture<SWCSpectrum> > L, float gain,
00038 const string &texname, float fov);
00039 virtual ~ProjectionLight();
00040 virtual bool IsDeltaLight() const { return true; }
00041 virtual bool IsEnvironmental() const { return false; }
00042 RGBColor Projection(const Vector &w) const;
00043 virtual SWCSpectrum Power(const TsPack *tspack, const Scene *) const {
00044 return Lbase->Evaluate(tspack, dummydg) * gain *
00045 2.f * M_PI * (1.f - cosTotalWidth) *
00046 SWCSpectrum(tspack, projectionMap->Lookup(.5f, .5f, .5f));
00047 }
00048 virtual SWCSpectrum Sample_L(const TsPack *tspack, const Point &P, float u1, float u2, float u3,
00049 Vector *wo, float *pdf, VisibilityTester *visibility) const;
00050 virtual SWCSpectrum Sample_L(const TsPack *tspack, const Scene *scene, float u1, float u2,
00051 float u3, float u4, Ray *ray, float *pdf) const;
00052 virtual float Pdf(const Point &, const Vector &) const;
00053 virtual float Pdf(const Point &p, const Normal &n,
00054 const Point &po, const Normal &ns) const;
00055
00056 static Light *CreateLight(const Transform &light2world,
00057 const ParamSet ¶mSet, const TextureParams &tp);
00058 private:
00059
00060 MIPMap<RGBColor> *projectionMap;
00061 Point lightPos;
00062 boost::shared_ptr< Texture<SWCSpectrum> > Lbase;
00063 DifferentialGeometry dummydg;
00064 float gain;
00065 Transform lightProjection;
00066 float hither, yon;
00067 float screenX0, screenX1, screenY0, screenY1;
00068 float cosTotalWidth;
00069 };
00070
00071 }