DiffuseBSDF.cpp
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file DiffuseBSDF.cpp 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @author Matthew Jacobs (jacobs.mh@gmail.com) 00005 @date Fall 2008 00006 00007 @brief 00008 Ideal diffuse BSDF (lambertian) defined at a single point on a 00009 surface in 3-space 00010 00011 @param 00012 kd - SpectralSampleSet which scales / attenuates the overall reflectance 00013 of the material (diffuse albedo) 00014 <!-------------------------------------------------------------------->**/ 00015 00016 #include "DiffuseBSDF.h" 00017 #include <Material.h> 00018 #include <Random.h> 00019 00020 Event DiffuseBSDF::sample() { 00021 if (m_pt.normal.dot(m_wi) > 0) 00022 return Event(Vector3(), this); // absorbed 00023 00024 const Vector3 &wo = Vector3::cosRandom(m_pt.normalS); 00025 00026 return Event(wo, this); 00027 } 00028 00029 real_t DiffuseBSDF::getPdf(const Event &event) { 00030 if (m_pt.normal.dot(m_wi) > 0) 00031 return 0; 00032 00033 const Vector3 &wo = event.getValue<const Vector3&>(); 00034 const real_t cosA = m_pt.normal.dot(wo); 00035 00036 return (cosA > 0 ? 1.0 / M_PI : 0); 00037 } 00038 00039 SpectralSampleSet DiffuseBSDF::getBSDF(const Vector3 &wi, const Vector3 &wo) { 00040 if (m_pt.normal.dot(wi) >= 0 || m_pt.normal.dot(wo) <= 0) // one-sided BRDF 00041 return SpectralSampleSet::black(); 00042 00043 const SpectralSampleSet &kd = 00044 m_parent->getSpectralSampleSet("kd", SpectralSampleSet::fill(0.5), m_pt); 00045 00046 return kd / M_PI; 00047 } 00048
Generated on 28 Feb 2009 for Milton by
1.5.6