Nori

include/nori/bsdf.h

Go to the documentation of this file.
00001 /*
00002     This file is part of Nori, a simple educational ray tracer
00003 
00004     Copyright (c) 2012 by Wenzel Jakob and Steve Marschner.
00005 
00006     Nori is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License Version 3
00008     as published by the Free Software Foundation.
00009 
00010     Nori is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #if !defined(__BSDF_H)
00020 #define __BSDF_H
00021 
00022 #include <nori/object.h>
00023 
00024 NORI_NAMESPACE_BEGIN
00025 
00026 
00027 /**
00028  * \brief Convenience data structure used to pass multiple
00029  * parameters to the evaluation and sampling routines in \ref BSDF
00030  */
00031 struct BSDFQueryRecord {
00032         /// Incident direction (in the local frame)
00033         Vector3f wi;
00034 
00035         /// Outgoing direction (in the local frame)
00036         Vector3f wo;
00037 
00038         /// Measure associated with the sample
00039         EMeasure measure;
00040 
00041         /// Create a new record for sampling the BSDF
00042         inline BSDFQueryRecord(const Vector3f &wi)
00043                 : wi(wi), measure(EUnknownMeasure) { }
00044 
00045         /// Create a new record for querying the BSDF
00046         inline BSDFQueryRecord(const Vector3f &wi,
00047                         const Vector3f &wo, EMeasure measure) 
00048                 : wi(wi), wo(wo), measure(measure) { }
00049 };
00050 
00051 /**
00052  * \brief Superclass of all bidirectional scattering distribution functions
00053  */
00054 class BSDF : public NoriObject {
00055 public:
00056         /**
00057          * \brief Sample the BSDF and return the importance weight (i.e. the
00058          * value of the BSDF * cos(theta_o) divided by the probability density 
00059          * of the sample with respect to solid angles). 
00060          *
00061          * \param bRec    A BSDF query record
00062          * \param sample  A uniformly distributed sample on \f$[0,1]^2\f$
00063          *
00064          * \return The BSDF value divided by the probability density of the sample
00065          *         sample. The returned value also includes the cosine
00066          *         foreshortening factor associated with the outgoing direction,
00067          *         when this is appropriate. A zero value means that sampling
00068          *         failed.
00069          */
00070         virtual Color3f sample(BSDFQueryRecord &bRec, const Point2f &sample) const = 0;
00071 
00072         /**
00073          * \brief Evaluate the BSDF for a pair of directions and measure
00074          * specified in \code bRec
00075          * 
00076          * \param bRec
00077          *     A record with detailed information on the BSDF query
00078          * \return
00079          *     The BSDF value, evaluated for each color channel
00080          */
00081         virtual Color3f eval(const BSDFQueryRecord &bRec) const = 0;
00082 
00083         /**
00084          * \brief Compute the probability of sampling \c bRec.wo
00085          * (conditioned on \c bRec.wi).
00086          *
00087          * This method provides access to the probability density that
00088          * is realized by the \ref sample() method.
00089          *
00090          * \param bRec
00091          *     A record with detailed information on the BSDF query
00092          *
00093          * \return
00094          *     A probability/density value expressed with respect
00095          *     to the specified measure
00096          */
00097 
00098         virtual float pdf(const BSDFQueryRecord &bRec) const = 0;
00099         
00100         /**
00101          * \brief Return the type of object (i.e. Mesh/BSDF/etc.) 
00102          * provided by this instance
00103          * */
00104         EClassType getClassType() const { return EBSDF; }
00105 };
00106 
00107 NORI_NAMESPACE_END
00108 
00109 #endif /* __BSDF_H */
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines