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 "texture.h"
00027 #include "shape.h"
00028 #include "scene.h"
00029 #include "spd.h"
00030
00031 namespace lux
00032 {
00033
00034
00035 class SkyLight : public Light {
00036 public:
00037
00038 SkyLight(const Transform &light2world, const float skyscale, int ns, Vector sd, float turb, float aconst, float bconst, float cconst, float dconst, float econst);
00039 ~SkyLight();
00040 SWCSpectrum Power(const Scene *scene) const {
00041 Point worldCenter;
00042 float worldRadius;
00043 scene->WorldBound().BoundingSphere(&worldCenter,
00044 &worldRadius);
00045
00046 return skyScale * M_PI * worldRadius * worldRadius;
00047 }
00048 bool IsDeltaLight() const { return false; }
00049 SWCSpectrum Le(const RayDifferential &r) const;
00050 SWCSpectrum Le(const Scene *scene, const Ray &r,
00051 const Normal &n, BSDF **bsdf, float *pdf, float *pdfDirect) const;
00052 SWCSpectrum Sample_L(const Point &p, const Normal &n,
00053 float u1, float u2, float u3, Vector *wi, float *pdf,
00054 VisibilityTester *visibility) const;
00055 SWCSpectrum Sample_L(const Point &p, float u1, float u2, float u3,
00056 Vector *wi, float *pdf, VisibilityTester *visibility) const;
00057 SWCSpectrum Sample_L(const Scene *scene, float u1, float u2,
00058 float u3, float u4, Ray *ray, float *pdf) const;
00059 float Pdf(const Point &, const Normal &, const Vector &) const;
00060 float Pdf(const Point &, const Vector &) const;
00061 SWCSpectrum Sample_L(const Point &P, Vector *w, VisibilityTester *visibility) const;
00062 SWCSpectrum Sample_L(const Scene *scene, float u1, float u2, BSDF **bsdf, float *pdf) const;
00063 SWCSpectrum Sample_L(const Scene *scene, const Point &p, const Normal &n, float u1, float u2, float u3, BSDF **bsdf, float *pdf, float *pdfDirect, VisibilityTester *visibility) const;
00064
00065 static Light *CreateLight(const Transform &light2world,
00066 const ParamSet ¶mSet);
00067
00068
00069 Vector GetSunPosition() const;
00070 void SunThetaPhi(float &theta, float &phi) const;
00071 Spectrum GetSunSpectralRadiance() const;
00072 float GetSunSolidAngle() const;
00073 void GetSkySpectralRadiance(const float theta, const float phi, SWCSpectrum * const dst_spect) const;
00074 void GetAtmosphericEffects(const Vector &viewer, const Vector &source,
00075 Spectrum &atmAttenuation, Spectrum &atmInscatter ) const;
00076
00077 void InitSunThetaPhi();
00078 void ChromaticityToSpectrum(const float x, const float y, SWCSpectrum * const dst_spect) const;
00079 float PerezFunction(const float *lam, float theta, float phi, float lvz) const;
00080
00081 private:
00082
00083 float skyScale;
00084 Vector sundir;
00085 float turbidity;
00086 float thetaS, phiS;
00087 float zenith_Y, zenith_x, zenith_y;
00088 float perez_Y[6], perez_x[6], perez_y[6];
00089 };
00090
00091 }
00092