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 #include "lux.h" 00024 #include "texture.h" 00025 #include "color.h" 00026 #include "sampling.h" 00027 #include "paramset.h" 00028 #include "primitive.h" 00029 00030 // TODO - radiance - add methods for Power and Illuminant propagation 00031 00032 namespace lux 00033 { 00034 00035 // Dade - must be power of 2 00036 #define HARLEQUIN_TEXTURE_PALETTE_SIZE 0x1f 00037 00038 // Harlequin Declarations 00039 class HarlequinTexture : public Texture<SWCSpectrum> { 00040 public: 00041 // Harlequin Public Methods 00042 HarlequinTexture() { 00043 float c[3]; 00044 for (int i = 0; i < HARLEQUIN_TEXTURE_PALETTE_SIZE; i++) { 00045 c[0] = RadicalInverse(i * COLOR_SAMPLES + 1, 2); 00046 c[1] = RadicalInverse(i * COLOR_SAMPLES + 1, 3); 00047 c[2] = RadicalInverse(i * COLOR_SAMPLES + 1, 5); 00048 00049 ColorLookupTable[i] = RGBColor(c); 00050 } 00051 } 00052 virtual ~HarlequinTexture() { } 00053 00054 virtual SWCSpectrum Evaluate(const TsPack *tspack, const DifferentialGeometry &dg) const { 00055 // Dade - I assume object are 8 bytes aligned 00056 u_long lookupIndex = (((u_long)dg.handle) & 00057 ((HARLEQUIN_TEXTURE_PALETTE_SIZE-1) << 3)) >> 3; 00058 00059 return SWCSpectrum(tspack, ColorLookupTable[lookupIndex]); 00060 } 00061 00062 static Texture<float> *CreateFloatTexture(const Transform &tex2world, const TextureParams &tp); 00063 static Texture<SWCSpectrum> *CreateSWCSpectrumTexture(const Transform &tex2world, const TextureParams &tp); 00064 00065 private: 00066 static RGBColor ColorLookupTable[]; 00067 }; 00068 00069 RGBColor HarlequinTexture::ColorLookupTable[HARLEQUIN_TEXTURE_PALETTE_SIZE]; 00070 00071 // Harlequin Method Definitions 00072 Texture<float> *HarlequinTexture::CreateFloatTexture(const Transform &tex2world, 00073 const TextureParams &tp) { 00074 return NULL; 00075 } 00076 00077 Texture<SWCSpectrum> *HarlequinTexture::CreateSWCSpectrumTexture(const Transform &tex2world, 00078 const TextureParams &tp) { 00079 return new HarlequinTexture(); 00080 } 00081 00082 }//namespace lux