Emitter.h
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @class Emitter 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @author Matthew Jacobs (jacobs.mh@gmail.com) 00005 @date Fall 2008 00006 00007 @brief 00008 Abstract representation of emittance defined at a single point on a 00009 surface in 3-space (describing a light). 00010 00011 The reason Emitter subclasses BSDF is for convenience during generation 00012 and evaluation of paths in bidirectional path tracing. Emittance at a 00013 point in a given direction, Le(x,wo), is broken into two parts, 00014 Le0(x), and Le1(x), 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 light source, which can be viewed as a special case 00018 of scattering with no incident vector (the incident vector is thus 00019 disregarded). 00020 00021 @see Emitter::getBSDF() or the Path class for more details. 00022 <!-------------------------------------------------------------------->**/ 00023 00024 #ifndef EMITTER_H_ 00025 #define EMITTER_H_ 00026 00027 #include <materials/BSDF.h> 00028 00029 class Emitter : public BSDF { 00030 public: 00031 ///@name Constructors 00032 //@{----------------------------------------------------------------- 00033 00034 inline Emitter(SurfacePoint &pt, Sampler *sampler = NULL, 00035 Material *parent = NULL) 00036 : BSDF(pt, parent), m_pt(pt), m_parent(parent), m_sampler(sampler) 00037 { } 00038 00039 virtual ~Emitter() { 00040 safeDelete(m_sampler); 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 Emitter 00052 * 00053 * @note default implementation initializes power from PropertyMap and 00054 * calculates radiant exitance 00055 */ 00056 virtual void init(); 00057 00058 00059 //@}----------------------------------------------------------------- 00060 ///@name Main usage interface 00061 //@{----------------------------------------------------------------- 00062 00063 /** 00064 * @returns true iff this Emitter emits energy (is a light source) 00065 * 00066 * @note if 'isEmitter' returns false, 'getLe' and 'getPower' must 00067 * return SpectralSampleSet::black 00068 */ 00069 virtual bool isEmitter(); 00070 00071 /** 00072 * @returns the spectral radiance emitted along the given vector 00073 */ 00074 virtual SpectralSampleSet getLe(const Vector3 &wo) = 0; 00075 00076 /** 00077 * @returns the spectral power of this Emitter, representing the total 00078 * radiant energy emitted from surfaces associated with this Emitter 00079 * (with units watts) 00080 * 00081 * @note total Le emitted by integrating 'getLe' over the the sphere of 00082 * exitant directions and over the surface of the underlying shape 00083 * should equal the power of this emitter 00084 */ 00085 virtual SpectralSampleSet getPower(); 00086 00087 /** 00088 * @returns the spectral radiant exitance (aka radiosity) of the 00089 * surface containing this Emitter, where radiant exitance is 00090 * defined as power per unit surface area (with units watts/m^2) 00091 */ 00092 virtual SpectralSampleSet getRadiantExitance(); 00093 00094 /** 00095 * @returns Le0(x,0) which represents the total radiant exitance at this 00096 * point 00097 */ 00098 virtual SpectralSampleSet getLe0(); 00099 00100 /** 00101 * @returns Le1(x,wo) which represents the directional distribution of 00102 * radiant exitance in the given direction 00103 */ 00104 virtual SpectralSampleSet getLe1(const Vector3 &wo); 00105 00106 /** 00107 * @brief 00108 * Sets up OpenGL material state (light properties) to enable 00109 * a crude/fast preview of this light in OpenGL 00110 * 00111 * @note default implementation places a GL pointlight at the center 00112 * of the bounding box of the given shape 00113 */ 00114 virtual void preview(Shape *shape); 00115 00116 00117 //@}----------------------------------------------------------------- 00118 ///@name Sampling interface 00119 //@{----------------------------------------------------------------- 00120 00121 /** 00122 * @brief 00123 * Samples an exitent vector according to the underlying distribution 00124 * of emitted radiance at the surface point 00125 * 00126 * @returns the sampled vector 00127 */ 00128 virtual Event sample(); 00129 00130 /** 00131 * @returns the probability density of having sampled the given out 00132 * out vector 'event' with respect to whatever underlying sampling 00133 * strategy is being used to sample this Emitter 00134 */ 00135 virtual real_t getPdf(const Event &event); 00136 00137 /** 00138 * @brief 00139 * Mimics the behavior of a BSDF by separating emittance, Le(x,wo), 00140 * into two parts: Le0(x) and Le1(x,wo). 00141 * Le0(x) is independent of 'wo' and represents the total radiant 00142 * exitance emitted at point x. 00143 * Le1(x,wo) represents Le(x,w) / Le0(x), or in words, the 00144 * directional distribution of emitted radiance at x, corresponding to 00145 * the fraction of emitted radiance in direction 'wo' with respect to the 00146 * total radiant exitance emitted at point x. 00147 * 00148 * @returns the directional distribution of emitted radiance in 00149 * direction 'wo' 00150 * @note all implementations should disregard 'wi', as it has no physical 00151 * interpretation in the context of an Emitter 00152 * @note for details, see Eric Veach's thesis, section 8.3.2 00153 */ 00154 virtual SpectralSampleSet getBSDF(const Vector3 &wi, const Vector3 &wo); 00155 00156 00157 //@}----------------------------------------------------------------- 00158 ///@name Accessors/Mutators 00159 //@{----------------------------------------------------------------- 00160 00161 /** 00162 * @returns the SurfacePoint at which this Emitter instance is defined 00163 */ 00164 inline SurfacePoint &getSurfacePoint() { 00165 return m_pt; 00166 } 00167 00168 /** 00169 * @returns the parent Material which instantiated this Emitter 00170 * 00171 * @note the parent Material is also a PropertyMap and contians all 00172 * key-value inputs to this Emitter 00173 */ 00174 inline Material *getParent() { 00175 return m_parent; 00176 } 00177 00178 00179 //@}----------------------------------------------------------------- 00180 00181 protected: 00182 SurfacePoint &m_pt; 00183 Material *m_parent; 00184 00185 // total spectral radiance emitted (units watts) 00186 SpectralSampleSet m_power; 00187 00188 // power per unit surface area (units watts/m^2) 00189 SpectralSampleSet m_radiantExitance; 00190 00191 Sampler *m_sampler; 00192 }; 00193 00194 #endif // EMITTER_H_ 00195
Generated on 28 Feb 2009 for Milton by
1.5.6