Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

bsdf.h

Go to the documentation of this file.
00001 /*
00002     toxic - A Global Illumination Renderer
00003     Copyright (C) 2003-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of toxic.
00007 
00008     toxic is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     toxic is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with toxic; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef TOXIC_RENDERER_BSDF_H
00024 #define TOXIC_RENDERER_BSDF_H
00025 
00026 #include "common/math/real.h"
00027 #include "common/math/vector3.h"
00028 #include "globals.h"
00029 #include "ibdf.h"
00030 
00031 #include <utility>  // std::pair<>, std::make_pair<>()
00032 #include <vector>
00033 
00034 namespace toxic {
00035 
00036     class Context;
00037 
00038     //! Bidirectional Scattering Distribution Function (BSDF).
00039     class BSDF : public IBDF {
00040     public:
00041         BSDF();
00042 
00043         virtual ~BSDF() {}
00044 
00045         virtual bool IsDiffuse() const;
00046         virtual bool IsSpecular() const;
00047 
00048         void Insert(const IBRDF *brdf, sheep::Real weight);
00049         void Insert(const IBTDF *btdf, sheep::Real weight);
00050 
00051         //! Evaluates the function. Both the incoming and outgoing directions are
00052         //! expressed in local space.
00053         virtual sheep::Real Evaluate(
00054             const Context &context,
00055             const sheep::Vector3 &incoming,
00056             const sheep::Vector3 &outgoing) const;
00057 
00058         virtual sheep::Real EvaluateSpecular(
00059             const Context &context,
00060             const sheep::Vector3 &incoming,
00061             sheep::Vector3 *outgoing) const;
00062 
00063         //! Samples the function in order to obtain an outgoing direction, given
00064         //! an incoming direction. The probability with which the direction has
00065         //! been chosen is also computed. Both incoming and outgoing directions
00066         //! are expressed in local space.
00067         virtual void Sample(
00068             const Context &context,
00069             const sheep::Vector3 &incoming,
00070             sheep::Vector3 *outgoing,
00071             sheep::Real *prob,
00072             sheep::Real *value) const;
00073 
00074         //! Computes the probability of scattering from 'incoming' direction to
00075         //! 'outgoing' direction. Both incoming and outgoing directions are
00076         //! expressed in local space.
00077         virtual sheep::Real ComputeScatteringProbability(
00078             const sheep::Vector3 &incoming,
00079             const sheep::Vector3 &outgoing) const;
00080 
00081         //! Computes and returns the hemispherical hemispherical reflectance.
00082         virtual sheep::Real ComputeReflectance(const Context &context) const;
00083 
00084         //! Computes and returns the directional hemispherical reflectance. The
00085         //! incoming direction is expressed in local space.
00086         virtual sheep::Real ComputeReflectance(
00087             const Context &context,
00088             const sheep::Vector3 &incoming) const;
00089 
00090     private:
00091         typedef std::pair<const IBRDF *, sheep::Real> weighted_brdf;
00092         typedef std::pair<const IBTDF *, sheep::Real> weighted_btdf;
00093 
00094         typedef std::vector<weighted_brdf> brdf_vector;
00095         typedef std::vector<weighted_btdf> btdf_vector;
00096 
00097         typedef brdf_vector::const_iterator brdf_vector_const_it;
00098         typedef btdf_vector::const_iterator btdf_vector_const_it;
00099 
00100         brdf_vector m_brdfs;            //!< Vector of all BRDFs.
00101         btdf_vector m_btdfs;            //!< Vector of all BTDFs.
00102         brdf_vector m_specular_brdfs;   //!< Vector of specular BRDFs.
00103         btdf_vector m_specular_btdfs;   //!< Vector of specular BTDFs.
00104 
00105         sheep::Real m_total_weight;     //!< The total weight of all components (BRDFs and BTDFs).
00106     };
00107 
00108 #include "bsdf.inl"
00109 
00110 }
00111 
00112 #endif  // !TOXIC_RENDERER_BSDF_H

Generated on Tue May 11 01:31:49 2004 for toxic by doxygen 1.3.6