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 // uv.cpp* 00024 #include "lux.h" 00025 #include "texture.h" 00026 #include "paramset.h" 00027 00028 // TODO - radiance - add methods for Power and Illuminant propagation 00029 00030 namespace lux 00031 { 00032 00033 // UVTexture Declarations 00034 class UVTexture : public Texture<SWCSpectrum> { 00035 public: 00036 // UVTexture Public Methods 00037 UVTexture(TextureMapping2D *m) { 00038 mapping = m; 00039 } 00040 virtual ~UVTexture() { 00041 delete mapping; 00042 } 00043 virtual SWCSpectrum Evaluate(const TsPack *tspack, const DifferentialGeometry &dg) const { 00044 float s, t, dsdx, dtdx, dsdy, dtdy; 00045 mapping->Map(dg, &s, &t, &dsdx, &dtdx, &dsdy, &dtdy); 00046 float cs[COLOR_SAMPLES]; 00047 memset(cs, 0, COLOR_SAMPLES * sizeof(float)); 00048 cs[0] = s - Floor2Int(s); 00049 cs[1] = t - Floor2Int(t); 00050 return SWCSpectrum(tspack, RGBColor(cs)); 00051 } 00052 00053 static Texture<float> * CreateFloatTexture(const Transform &tex2world, const TextureParams &tp); 00054 static Texture<SWCSpectrum> * CreateSWCSpectrumTexture(const Transform &tex2world, const TextureParams &tp); 00055 private: 00056 TextureMapping2D *mapping; 00057 }; 00058 00059 }//namespace lux 00060