00001 /*************************************************************************** 00002 * Copyright (C) 1998-2008 by authors (see AUTHORS.txt ) * 00003 * * 00004 * This file is part of LuxRender. * 00005 * * 00006 * Lux Renderer is free software; you can redistribute it and/or modify * 00007 * it under the terms of the GNU General Public License as published by * 00008 * the Free Software Foundation; either version 3 of the License, or * 00009 * (at your option) any later version. * 00010 * * 00011 * Lux Renderer is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 00018 * * 00019 * This project is based on PBRT ; see http://www.pbrt.org * 00020 * Lux Renderer website : http://www.luxrender.net * 00021 ***************************************************************************/ 00022 00023 // environment.cpp* 00024 #include "camera.h" 00025 00026 namespace lux 00027 { 00028 00029 // EnvironmentCamera Declarations 00030 class EnvironmentCamera : public Camera { 00031 public: 00032 // EnvironmentCamera Public Methods 00033 EnvironmentCamera(const Transform &world2cam, float hither, 00034 float yon, float sopen, float sclose, Film *film); 00035 float GenerateRay(const Sample &sample, Ray *) const; 00036 bool IsVisibleFromEyes(const Scene *scene, const Point &lenP, const Point &worldP, Sample* sample_gen, Ray *ray_gen) const; 00037 float GetConnectingFactor(const Point &lenP, const Point &worldP, const Vector &wo, const Normal &n) const; 00038 void GetFlux2RadianceFactors(Film *film, float *factors, int xPixelCount, int yPixelCount) const; 00039 bool IsDelta() const 00040 { 00041 return true; 00042 } 00043 void SamplePosition(float u1, float u2, Point *p, float *pdf) const; 00044 float EvalPositionPdf() const; 00045 //float SampleDirection(const Sample &sample, Ray *ray) 00046 //{ 00047 // // FixMe: Duplicated code 00048 // ray->o = rayOrigin; 00049 // // Generate environment camera ray direction 00050 // float theta = M_PI * sample.imageY / film->yResolution; 00051 // float phi = 2 * M_PI * sample.imageX / film->xResolution; 00052 // Vector dir(sinf(theta) * cosf(phi), cosf(theta), 00053 // sinf(theta) * sinf(phi)); 00054 // CameraToWorld(dir, &ray->d); 00055 // // Set ray time value 00056 // ray->time = Lerp(sample.time, ShutterOpen, ShutterClose); 00057 // ray->mint = ClipHither; 00058 // ray->maxt = ClipYon; 00059 00060 // // R*R/(Apixel*nx*ny) 00061 // // sub-pdf in Apixel is not correct 00062 // return 1.0f/(2.0f*M_PI*M_PI*sinf(M_PI*((int)sample.imageY+0.5f)/film->yResolution)); 00063 00064 //} 00065 //float EvalDirectionPdf(Film *film, const Vector& wo, const Sample &sample, const Point& p) 00066 //{ 00067 // return 1.0f/(2.0f*M_PI*M_PI*sinf(M_PI*((int)sample.imageY+0.5f)/film->yResolution)); 00068 //} 00069 //SWCSpectrum EvalValue() 00070 //{ 00071 // return SWCSpectrum(1.0f); 00072 //} 00073 static Camera *CreateCamera(const ParamSet ¶ms, const Transform &world2cam, Film *film); 00074 private: 00075 bool GenerateSample(const Point &p, Sample *sample) const; 00076 // EnvironmentCamera Private Data 00077 Point rayOrigin; 00078 }; 00079 00080 }//namespace lux