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

ibdf.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_IBDF_H
00024 #define TOXIC_RENDERER_IBDF_H
00025 
00026 #include "common/math/real.h"
00027 #include "common/math/sampling.h"
00028 #include "common/math/vector3.h"
00029 #include "common/misc/iclonable.h"
00030 #include "context.h"
00031 #include "globals.h"
00032 
00033 #include <cassert>
00034 
00035 namespace toxic {
00036 
00037     //! Bidirectional Distribution Function (BDF).
00038 
00039     //! Incoming and outgoing directions are both always expressed in the upper
00040     //! part of the unit hemisphere, and they are always unit-length.
00041 
00042     class IBDF : public sheep::IClonable<IBDF> {
00043     public:
00044         virtual ~IBDF() {}
00045 
00046         virtual bool IsDiffuse() const { return true; }
00047         virtual bool IsSpecular() const { return false; }
00048 
00049         //! Evaluates the function. Both the incoming and outgoing directions are
00050         //! expressed in local space.
00051         virtual sheep::Real Evaluate(
00052             const Context &context,
00053             const sheep::Vector3 &incoming,
00054             const sheep::Vector3 &outgoing
00055         ) const = 0;
00056 
00057         virtual sheep::Real EvaluateSpecular(
00058             const Context &context,
00059             const sheep::Vector3 &incoming,
00060             sheep::Vector3 *outgoing
00061         ) 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         //! Note: this method must be overridden if the IsSpecular() method is
00068         //! defined to return true.
00069         virtual void Sample(
00070             const Context &context,
00071             const sheep::Vector3 &incoming,
00072             sheep::Vector3 *outgoing,
00073             sheep::Real *prob,
00074             sheep::Real *value
00075         ) const;
00076 
00077         //! Computes the probability of scattering from 'incoming' direction to
00078         //! 'outgoing' direction. Both incoming and outgoing directions are
00079         //! expressed in local space.
00080         //! Notes: (1) this method must be overridden if the Sample() method is
00081         //! overridden, (2) this method must return 0.0 if the IsSpecular() method
00082         //! is defined to return true.
00083         virtual sheep::Real ComputeScatteringProbability(
00084             const sheep::Vector3 &incoming,
00085             const sheep::Vector3 &outgoing
00086         ) const;
00087 
00088         //! Computes and returns the hemispherical hemispherical reflectance.
00089         //! Note: this method must be overridden if the IsSpecular() method is defined
00090         //! to return true.
00091         virtual sheep::Real ComputeReflectance(const Context &context) const;
00092 
00093         //! Computes and returns the directional hemispherical reflectance. The
00094         //! incoming direction is expressed in local space.
00095         //! Note: this method must be overridden if the IsSpecular() method is defined
00096         //! to return true.
00097         virtual sheep::Real ComputeReflectance(
00098             const Context &context,
00099             const sheep::Vector3 &incoming
00100         ) const;
00101     };
00102 
00103     //! Bidirectional Reflectance Distribution Function (BRDF).
00104     class IBRDF : public IBDF {
00105     public:
00106         virtual ~IBRDF() {}
00107     };
00108 
00109     //! Bidirectional Transmittance Distribution Function (BTDF).
00110     class IBTDF : public IBDF {
00111     public:
00112         virtual ~IBTDF() {}
00113     };
00114 
00115 #include "ibdf.inl"
00116 
00117 }
00118 
00119 #endif  // !TOXIC_RENDERER_IBDF_H

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