PathVertex.cpp

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @file   PathVertex.h
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @author Matthew Jacobs (jacobs.mh@gmail.com)
00005    @date   Fall 2008
00006    
00007    @brief
00008       A Path is composed of zero or more PathVertex vertices stored in a 
00009    PathVertexList.  Each PathVertex stores the underlying SurfacePoint, 
00010    representing a single point on a surface (and all relevant associated 
00011    metadata, eg, UV coords, normal, BSDF, etc.).  In addition to storing 
00012    the underlying SurfacePoint, each PathVertex also stores a set of 
00013    carefully chosen, local values which facilitate efficient computation
00014    of the unweighted, bidirectional contributions of all possible 
00015    combinations of light and eye subpaths.  Specifically, 'alphaL' and 
00016    'alphaE' store the cumulative light and eye contributions respectively, 
00017    with respect to this vertex' index within its parent Path.
00018    
00019    @note
00020       Density with respect to projected solid angle is density with respect to 
00021    ordinary solid angle divided by cos(theta) where theta is the angle between 
00022    wo and the surface normal at v (PathVertex::pdfL and PathVertex::pdfE are 
00023    both probability densities with respect to projected solid angle)
00024    
00025    @see section 10.2 (pgs 302-305) of Veach's thesis for more details
00026    <!-------------------------------------------------------------------->**/
00027 
00028 #include <PathVertex.h>
00029 #include <Material.h>
00030 
00031 PathVertex::PathVertex(SurfacePoint *pt_, real_t pL_, real_t pE_)
00032    : pt(SurfacePointPtr(pt_)), bsdf(pt->bsdf), GL(1), GE(1), 
00033      alphaL(SpectralSampleSet::identity() / pL_), 
00034      alphaE(SpectralSampleSet::identity() / pE_), 
00035      pdfL(1), pdfE(1), pL(pL_), pE(pE_)
00036 {
00037    ASSERT(pt_);
00038    
00039    if (pt->emitter->isEmitter()) {
00040       alphaL = pt->emitter->getLe0() / pL;
00041    } else if (pt->sensor->isSensor()) {
00042       alphaE = pt->sensor->getWe0()  / pE;
00043    }
00044    
00045    wi = -pt->normalS;
00046    _init();
00047 }
00048 
00049 void PathVertex::_init() {
00050    ASSERT(pt.get() != NULL);
00051    ASSERT(pt.use_count() > 0);
00052    ASSERT(pt->emitter && pt->sensor);
00053    
00054    if (pt->emitter->isEmitter()) {
00055       bsdf = pt->emitter;
00056    } else if (pt->sensor->isSensor()) {
00057       bsdf = pt->sensor;
00058    } else {
00059       bsdf = pt->bsdf;
00060    }
00061    
00062    ASSERT(bsdf);
00063    bsdf->setWi(wi);
00064    
00065    // the same metadata will be used for all future BSDF evaluations
00066    // at this PathVertex
00067    event = bsdf->sample();
00068 }
00069 
00070 std::ostream &operator<<(std::ostream &os, const PathVertex &v) {
00071    const bool emitter = (v.bsdf == v.pt->emitter);
00072    const bool sensor  = (v.bsdf == v.pt->sensor );
00073    
00074    os << "{ " << (sensor ? "camera" : (emitter ? "light" : "")) << endl
00075       //<< "  pt     = " << (*v.pt.get()) << endl
00076       << "  GL     = " << v.GL << endl
00077       << "  GE     = " << v.GE << endl
00078       << "  alphaL = " << v.alphaL << endl
00079       << "  alphaE = " << v.alphaE << endl
00080       << "  fs     = " << v.fs << endl
00081       << "  pdfL   = " << v.pdfL << endl
00082       << "  pdfE   = " << v.pdfE << endl
00083       << "  pL     = " << v.pL << endl
00084       << "  pE     = " << v.pE << endl;
00085    
00086    if (emitter)
00087       os << "  Le0    = " << v.pt->emitter->getLe0() << endl;
00088    
00089    if (sensor)
00090       os << "  We0    = " << v.pt->sensor->getWe0() << endl;
00091    
00092    os << "}";
00093    return os;
00094 }
00095 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6