00001 /*************************************************************************** 00002 * Copyright (C) 1998-2009 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 // blackbody.cpp* 00024 #include "lux.h" 00025 #include "texture.h" 00026 #include "blackbodyspd.h" 00027 #include "paramset.h" 00028 00029 namespace lux 00030 { 00031 00032 // BlackBodyTexture Declarations 00033 template <class T> 00034 class BlackBodyFloatTexture : public Texture<T> { 00035 public: 00036 // BlackBodyTexture Public Methods 00037 BlackBodyFloatTexture(const T &v) { value = v; } 00038 virtual ~BlackBodyFloatTexture() { } 00039 virtual T Evaluate(const TsPack *tspack, const DifferentialGeometry &) const { 00040 return value; 00041 } 00042 private: 00043 T value; 00044 }; 00045 00046 template <class T> 00047 class BlackBodySpectrumTexture : public Texture<T> { 00048 public: 00049 // BlackBodyTexture Public Methods 00050 BlackBodySpectrumTexture(const float &t) { 00051 BBSPD = new BlackbodySPD(t); 00052 } 00053 virtual ~BlackBodySpectrumTexture() { delete BBSPD; } 00054 virtual T Evaluate(const TsPack *tspack, const DifferentialGeometry &) const { 00055 return SWCSpectrum(tspack, BBSPD); 00056 } 00057 virtual void SetPower(float power, float area) { 00058 float Y = BBSPD->Y(); 00059 if (!(Y > 0)) 00060 return; 00061 BBSPD->Scale(power / (area * M_PI * Y)); 00062 } 00063 00064 private: 00065 BlackbodySPD* BBSPD; 00066 }; 00067 00068 class BlackBodyTexture 00069 { 00070 public: 00071 static Texture<float> * CreateFloatTexture(const Transform &tex2world, const TextureParams &tp); 00072 static Texture<SWCSpectrum> * CreateSWCSpectrumTexture(const Transform &tex2world, const TextureParams &tp); 00073 }; 00074 00075 }//namespace lux 00076