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