Sensor.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  Sensor
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 #ifndef SENSOR_H_
00025 #define SENSOR_H_
00026 
00027 #include <materials/BSDF.h>
00028 
00029 class Camera;
00030 
00031 class Sensor : public BSDF {
00032    public:
00033       ///@name Constructors
00034       //@{-----------------------------------------------------------------
00035       
00036       inline   Sensor(SurfacePoint &pt, Material *parent = NULL)
00037          : BSDF(pt, parent), m_pt(pt), m_parent(parent), m_camera(NULL)
00038       { }
00039       
00040       virtual ~Sensor() 
00041       { }
00042       
00043       
00044       //@}-----------------------------------------------------------------
00045       ///@name Initialization
00046       //@{-----------------------------------------------------------------
00047       
00048       /**
00049        * @brief
00050        *    Performs any initialization that may be necessary before beginning 
00051        * to use this sensor
00052        */
00053       virtual void init();
00054       
00055       
00056       //@}-----------------------------------------------------------------
00057       ///@name Main usage interface
00058       //@{-----------------------------------------------------------------
00059       
00060       /**
00061        * @returns true iff this sensor emits importance (is a valid sensor)
00062        * 
00063        * @note if 'isSensor' returns false, 'getWe' and 'getImportance' must 
00064        *    return SpectralSampleSet::black
00065        */
00066       virtual bool isSensor();
00067       
00068       /**
00069        * @returns the spectral importance emitted along the given vector
00070        */
00071       virtual SpectralSampleSet getWe(const Vector3 &wo);
00072       
00073       /**
00074        * @returns We0(x,0) which represents the total importance emitted at 
00075        *    this point
00076        */
00077       virtual SpectralSampleSet getWe0();
00078       
00079       /**
00080        * @returns We1(x,wo) which represents the directional distribution of 
00081        *    importance emitted in the given direction
00082        */
00083       virtual SpectralSampleSet getWe1(const Vector3 &wo);
00084       
00085       /**
00086        * @returns the spectral importance of this sensor, representing the 
00087        *    total radiant energy emitted from surfaces associated with this 
00088        *    sensor; TODO: what units?
00089        * 
00090        * @note total We emitted by integrating 'getWe' over the the sphere of 
00091        *    exitant directions should equal the importance of this sensor
00092        */
00093       virtual SpectralSampleSet getImportance();
00094       
00095       /**
00096        * @note implementation is empty
00097        */
00098       virtual void preview(Shape *shape)
00099       { }
00100       
00101       
00102       //@}-----------------------------------------------------------------
00103       ///@name Sampling interface
00104       //@{-----------------------------------------------------------------
00105       
00106       /**
00107        * @brief
00108        *    Samples an exitent vector according to the underlying distribution 
00109        * of emitted importance at the surface point
00110        * 
00111        * @returns the sampled vector
00112        */
00113       virtual Event sample();
00114       
00115       /**
00116        * @returns the probability density of having sampled the given out 
00117        *    out vector 'event' with respect to whatever underlying sampling 
00118        *    strategy is being used to sample this sensor
00119        */
00120       virtual real_t getPdf(const Event &event);
00121       
00122       /**
00123        * @brief
00124        *    Mimics the behavior of a BSDF by separating emittance, We(x,wo), 
00125        * into two parts: We0(x) and We1(x,wo).
00126        *    We0(x) is independent of 'wo' and represents the total 
00127        * importance emitted at point x.
00128        *    We1(x,wo) represents We(x,w) / We0(x), or in words, the 
00129        * directional distribution of importance emitted at x, corresponding to 
00130        * the fraction of importance emitted in direction 'wo' with respect to the
00131        * total importance emitted at point x.
00132        * 
00133        * @returns the directional distribution of importance emitted in 
00134        *    direction 'wo'
00135        * @note all implementations should disregard 'wo', as it has no physical
00136        *    interpretation in the context of a sensor
00137        * @note for details, see Eric Veach's thesis, section 8.3.2
00138        */
00139       virtual SpectralSampleSet getBSDF(const Vector3 &wi, const Vector3 &wo);
00140       
00141       /**
00142        * @returns true iff this BSDF is non-zero over a set of solid angles 
00143        *    with measure zero (measured with respect to solid angle)
00144        * 
00145        * @note a perfectly specular material has a dirac distribution for its 
00146        *    reflectance, and therefore needs special consideration when 
00147        *    sampling the BRDF for simulation purposes
00148        * @note the default implementation returns false because perfectly
00149        *    specular surfaces don't occur that often in real life, though they 
00150        *    abound in computer graphics (due to their ease of simulation)
00151        */
00152       virtual bool isSpecular(Event &/* event unused*/) const {
00153          return true;
00154       }
00155       
00156       
00157       //@}-----------------------------------------------------------------
00158       ///@name Accessors/Mutators
00159       //@{-----------------------------------------------------------------
00160       
00161       inline SurfacePoint &getSurfacePoint() {
00162          return m_pt;
00163       }
00164       
00165       inline Material *getParent() {
00166          return m_parent;
00167       }
00168       
00169       
00170       //@}-----------------------------------------------------------------
00171       
00172    protected:
00173       SurfacePoint &m_pt;
00174       Material    *m_parent;
00175       
00176       Camera      *m_camera;
00177 };
00178 
00179 #endif // SENSOR_H_
00180 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6