Sensor.cpp
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file Sensor.cpp 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @author Matthew Jacobs (jacobs.mh@gmail.com) 00005 @date Fall 2008 00006 00007 @brief 00008 Representation of importance defined at a single point on a surface in 00009 3-space (describing a sensor / camera). 00010 00011 The reason Sensor subclasses BSDF is for convenience during generation 00012 and evaluation of paths in bidirectional path tracing. Importance at a 00013 point in a given direction, We(x,wo), is broken into two parts, 00014 We0(x), and We1(x,wo), as originally detailed by Veach and Guibas 00015 (see Eric Veach's thesis, section 8.3.2). Scattering at a vertex can then 00016 be uniformly viewed as evaluation / sampling of a BSDF, including initial, 00017 fake 'scattering' at a sensor, which can be viewed as a special case 00018 of scattering with no exitent vector (the exitent vector is thus 00019 disregarded). 00020 00021 @see Sensor::getBSDF() or the Path class for more details. 00022 <!-------------------------------------------------------------------->**/ 00023 00024 #include "Sensor.h" 00025 #include "Material.h" 00026 #include <Camera.h> 00027 00028 void Sensor::init() { 00029 ASSERT(m_pt.shape); 00030 ASSERT(m_parent); 00031 00032 m_camera = NULL; 00033 00034 try { 00035 m_camera = dynamic_cast<Camera*>(m_pt.shape); 00036 } catch(std::bad_cast&) { } 00037 00038 ASSERT(m_camera); 00039 BSDF::init(); 00040 } 00041 00042 bool Sensor::isSensor() { 00043 return (getImportance() != SpectralSampleSet::black()); 00044 } 00045 00046 SpectralSampleSet Sensor::getWe(const Vector3 &wo) { 00047 ASSERT(m_camera); 00048 00049 return SpectralSampleSet::fill(wo == m_pt.normalS); 00050 } 00051 00052 SpectralSampleSet Sensor::getImportance() { 00053 return SpectralSampleSet::identity(); 00054 } 00055 00056 SpectralSampleSet Sensor::getWe0() { 00057 return getImportance(); 00058 } 00059 00060 SpectralSampleSet Sensor::getWe1(const Vector3 &wo) { 00061 return getWe(wo) / getWe0(); 00062 } 00063 00064 00065 // TODO: modify Camera interface / implementation to accomodate stochastic 00066 // sampling w/ deterministic Pinhole camera as a special-case 00067 Event Sensor::sample() { 00068 ASSERT(m_camera); 00069 00070 /*const Ray &ray = m_camera->getWorldRay( 00071 Point2(m_pt.uv.u * m_camera->getWidth(), 00072 m_pt.uv.v * m_camera->getHeight())); 00073 00074 return Event(ray.direction, this);*/ 00075 00076 return Event(m_pt.normalS, this); 00077 } 00078 00079 real_t Sensor::getPdf(const Event &event) { 00080 const Vector3 &wo = event.getValue<const Vector3&>(); 00081 00082 if (m_wi == -m_pt.normalS) 00083 return 1; 00084 00085 // else adjoint 00086 return (wo == m_pt.normalS); 00087 } 00088 00089 SpectralSampleSet Sensor::getBSDF(const Vector3 &wi, 00090 const Vector3 &/* wo unused */) 00091 { 00092 return getWe1(-wi); 00093 /*if (wi == -m_pt.normalS) 00094 return getWe1(-wi); 00095 00096 // else adjoint 00097 return getWe1(wo);*/ 00098 } 00099
Generated on 28 Feb 2009 for Milton by
1.5.6