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 // specularreflection.cpp* 00024 #include "specularreflection.h" 00025 #include "color.h" 00026 #include "spectrum.h" 00027 #include "mc.h" 00028 #include "sampling.h" 00029 #include "fresnel.h" 00030 #include <stdarg.h> 00031 00032 using namespace lux; 00033 00034 SWCSpectrum SpecularReflection::Sample_f(const Vector &wo, 00035 Vector *wi, float u1, float u2, float *pdf, float *pdfBack) const { 00036 // Compute perfect specular reflection direction 00037 *wi = Vector(-wo.x, -wo.y, wo.z); 00038 *pdf = 1.f; 00039 if (pdfBack) 00040 *pdfBack = 1.f; 00041 return fresnel->Evaluate(CosTheta(wo)) * R / 00042 fabsf(CosTheta(*wi)); 00043 } 00044 00045 SWCSpectrum ArchitecturalReflection::Sample_f(const Vector &wo, 00046 Vector *wi, float u1, float u2, float *pdf, float *pdfBack) const 00047 { 00048 if (wo.z <= 0.f) { 00049 *pdf = 0.f; 00050 if (pdfBack) 00051 *pdfBack = 0.f; 00052 return 0.f; 00053 } 00054 return SpecularReflection::Sample_f(wo, wi, u1, u2, pdf, pdfBack); 00055 }